AndroidManifest File

AndroidManifest.xml

AndroidManifest.xml is a powerful file in the Android platform that allows you to describe the functionality and requirements of your application to Android.

Manifest file for an android application is a resource file which contains all the details needed by the android system about the application. It is a key file that works as a bridge between the android developer and the android platform. 

Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. It does the following things,


·        It names the Java package for the application. The package name serves as a unique identifier for the application.
·        It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.
·         It determines which processes will host application components.
·         It declares which permissions the application must have in order to access protected parts of the API and interact with other applications.
·         It also declares the permissions that others are required to have in order to interact with the application's components.
·         It lists the Instrumentation classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published.
·         It declares the minimum level of the Android API that the application requires.
·         It lists the libraries that the application must be linked against.

Few xml file conventions :

Only the <manifest> and <application> elements are required, they each must be present and can occur only once. 

Many elements correspond to Java objects, including elements for the application itself (the<application> element) and its principal components — activities (<activity>), services (<service>), broadcast receivers (<receiver>), and content providers (<provider>).

If more than one value can be specified, the element is almost always repeated, rather than listing multiple values within a single element.

Elements for Application Properties:


  • uses-permission – used to specify permissions that are requested for the purpose of security.
  • permission – used to set permissions to provide access control for some specific component of the application.
  • permission-group – does the same as above for a set of components.
  • permission-tree – refer one specific name of the component which is the owner or parent of the set of component.
  • instrumentation – enables to know interaction between Android system and application.
  • uses-sdk – specifies the platform compatibility of the application.
  • uses-configuration – specifies set of hardware and software requirement of the application.
  • uses-feature – specifies single hardware and software requirement and their related entity.
  • supports-screens, compatible-screens – both these tags deals with screen configuration mode and size of the screen and etc.


       Elements for Application Components :

              These should be enclosed in <application> container.


·         activity – has the set of attributes based on user interface.
·         activity-alias – specifies target activities.
·         service – has the operation provided by any library or API, running in background that is not visible.
·         receiver – that makes to receive message broadcasted by the same application or by outside entity.
·         provider – provides some structure to access application data.
·         uses-library – it specifies set of library files need to run the application.

AndroidManifest.xml : 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testdemo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testdemo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>




No comments:

Post a Comment