Saturday 26 November 2011

About Use of AndroidManifest.file in Android Project

Hello,Here are some Require Information From android developer to how we can manage androidmanifest.xml  in your android project.


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. Among other things, the manifest does the following:



  1. It names the Java package for the application. The package name serves as a unique identifier for the application.
  2. 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.
  3. It determines which processes will host application components.
  4. It declares which permissions the application must have in order to access protected parts of the API and interact with other applications.
  5. It also declares the permissions that others are required to have in order to interact with the application's components.
  6. 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.
  7. It declares the minimum level of the Android API that the application requires.
  8. It lists the libraries that the application must be linked against.


Structure of the Manifest File:

The diagram below shows the general structure of the manifest file and every element that it can contain. Each element, along with all of its attributes, is documented in full in a separate file. To view detailed information about any element, click on the element name in the diagram, in the alphabetical list of elements that follows the diagram, or on any other mention of the element name.
<?xml version="1.0" encoding="utf-8"?>
<manifest>

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration />  
    <uses-feature />  
    <supports-screens />  
    <compatible-screens />  
    <supports-gl-texture />  

    <application>

        <activity>
            <intent-filter>
                <action />
                <category />
                <data />
            </intent-filter>
            <meta-data />
        </activity>

        <activity-alias>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </activity-alias>

        <service>
            <intent-filter> . . . </intent-filter>
            <meta-data/>
        </service>

        <receiver>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </receiver>

        <provider>
            <grant-uri-permission />
            <meta-data />
        </provider>

        <uses-library />

    </application>
</manifest>

Here is Example of Sample use of all types of Each and Every Tag of Manifest.
For:<uses-permission />



syntax:
<uses-permission android:name="string" />
contained in:
<manifest>
description:
Requests a permission that the application must be granted in order for it to operate correctly. Permissions are granted by the user when the application is installed, not while it's running.
For more information on permissions, see the Permissions section in the introduction and the separate Security and Permissions document. A list of permissions defined by the base platform can be found at android.Manifest.permission.
attributes:
android:name
The name of the permission. It can be a permission defined by the application with the<permission> element, a permission defined by another application, or one of the standard system permissions, such as "android.permission.CAMERA" or "android.permission.READ_CONTACTS". As these examples show, a permission name typically includes the package name as a prefix.
introduced in:
API Level 1
see also:




syntax:
<permission android:description="string resource"
            android:icon="drawable resource"
            android:label="string resource"
            android:name="string"
            android:permissionGroup="string"
            android:protectionLevel=["normal" | "dangerous" | 
                                     "signature" | "signatureOrSystem"] />
contained in:
<manifest>
description:
Declares a security permission that can be used to limit access to specific components or features of this or other applications. See the Permissionssection in the introduction, and the Security and Permissions document for more information on how permissions work.
attributes:
android:description
A user-readable description of the permission, longer and more informative than the label. It may be displayed to explain the permission to the user — for example, when the user is asked whether to grant the permission to another application.
This attribute must be set as a reference to a string resource; unlike the label attribute, it cannot be a raw string.
android:icon
A reference to a drawable resource for an icon that represents the permission.
android:label
A name for the permission, one that can be displayed to users.
As a convenience, the label can be directly set as a raw string while you're developing the application. However, when the application is ready to be published, it should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.
android:name
The name of the permission. This is the name that will be used in code to refer to the permission — for example, in a <uses-permission> element and the permission attributes of application components.
The name must be unique, so it should use Java-style scoping — for example, "com.example.project.PERMITTED_ACTION".
android:permissionGroup
Assigns this permission to a group. The value of this attribute is the name of the group, which must be declared with the <permission-group>element in this or another application. If this attribute is not set, the permission does not belong to a group.
android:protectionLevel
Characterizes the potential risk implied in the permission and indicates the procedure the system should follow when determining whether or not to grant the permission to an application requesting it. The value can be set to one of the following strings:
ValueMeaning
"normal"The default value. A lower-risk permission that gives requesting applications access to isolated application-level features, with minimal risk to other applications, the system, or the user. The system automatically grants this type of permission to a requesting application at installation, without asking for the user's explicit approval (though the user always has the option to review these permissions before installing).
"dangerous"A higher-risk permission that would give a requesting application access to private user data or control over the device that can negatively impact the user. Because this type of permission introduces potential risk, the system may not automatically grant it to the requesting application. For example, any dangerous permissions requested by an application may be displayed to the user and require confirmation before proceeding, or some other approach may be taken to avoid the user automatically allowing the use of such facilities.
"signature"A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.
"signatureOrSystem"A permission that the system grants only to applications that are in the Android system image or that are signed with the same certificates as those in the system image. Please avoid using this option, as the signatureprotection level should be sufficient for most needs and works regardless of exactly where applications are installed. The "signatureOrSystem" permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together.
introduced in:
API Level 1
see also:
<uses-permission>
<permission-tree>
<permission-group>

<permission-tree>

syntax:
<permission-tree android:icon="drawable resource"
                 android:label="string resource" ]
                 android:name="string" />
contained in:
<manifest>
description:
Declares the base name for a tree of permissions. The application takes ownership of all names within the tree. It can dynamically add new permissions to the tree by calling PackageManager.addPermission(). Names within the tree are separated by periods ('.'). For example, if the base name iscom.example.project.taxes, permissions like the following might be added:
com.example.project.taxes.CALCULATE
com.example.project.taxes.deductions.MAKE_SOME_UP
com.example.project.taxes.deductions.EXAGGERATE
Note that this element does not declare a permission itself, only a namespace in which further permissions can be placed. See the <permission> element for information on declaring permissions.
attributes:
android:icon
An icon representing all the permissions in the tree. This attribute must be set as a reference to a drawable resource containing the image definition.
android:label
A user-readable name for the group. As a convenience, the label can be directly set as a raw string for quick and dirty programming. However, when the application is ready to be published, it should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.
android:name
The name that's at the base of the permission tree. It serves as a prefix to all permission names in the tree. Java-style scoping should be used to ensure that the name is unique. The name must have more than two period-separated segments in its path — for example, com.example.base is OK, butcom.example is not.
introduced in:
API Level 1
see also:
<permission>
<permission-group>
<uses-permission>

<permission-group>

syntax:
<permission-group android:description="string resource"
                  android:icon="drawable resource"
                  android:label="string resource"
                  android:name="string" />
contained in:
<manifest>
description:
Declares a name for a logical grouping of related permissions. Individual permission join the group through the permissionGroup attribute of the<permission> element. Members of a group are presented together in the user interface.
Note that this element does not declare a permission itself, only a category in which permissions can be placed. See the <permission> element for element for information on declaring permissions and assigning them to groups.
attributes:
android:description
User-readable text that describes the group. The text should be longer and more explanatory than the label. This attribute must be set as a reference to a string resource. Unlike the label attribute, it cannot be a raw string.
android:icon
An icon representing the permission. This attribute must be set as a reference to a drawable resource containing the image definition.
android:label
A user-readable name for the group. As a convenience, the label can be directly set as a raw string while you're developing the application. However, when the application is ready to be published, it should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.
android:name
The name of the group. This is the name that can be assigned to a <permission> element's <permissionGroup> attribute.
introduced in:
API Level 1
see also:
<permission>
<permission-tree>
<uses-permission>

<application>

syntax:
<application android:allowTaskReparenting=["true" | "false"]
             android:backupAgent="string"
             android:debuggable=["true" | "false"]
             android:description="string resource"
             android:enabled=["true" | "false"]
             android:hasCode=["true" | "false"]
             android:hardwareAccelerated=["true" | "false"]
             android:icon="drawable resource"
             android:killAfterRestore=["true" | "false"]
             android:label="string resource"
             android:logo="drawable resource"
             android:manageSpaceActivity="string"
             android:name="string"
             android:permission="string"
             android:persistent=["true" | "false"]
             android:process="string"
             android:restoreAnyVersion=["true" | "false"]
             android:taskAffinity="string"
             android:theme="resource or theme"
             android:uiOptions=["none" | "splitActionBarWhenNarrow"] >
    . . .</application>
contained in:
<manifest>
can contain:
<activity>
<activity-alias>
<service>
<receiver>
<provider>
<uses-library>
description:
The declaration of the application. This element contains subelements that declare each of the application's components and has attributes that can affect all the components. Many of these attributes (such as iconlabelpermissionprocesstaskAffinity, and allowTaskReparenting) set default values for corresponding attributes of the component elements. Others (such as debuggableenableddescription, and allowClearUserData) set values for the application as a whole and cannot be overridden by the components.
attributes
android:allowTaskReparenting
Whether or not activities that the application defines can move from the task that started them to the task they have an affinity for when that task is next brought to the front — "true" if they can move, and "false" if they must remain with the task where they started. The default value is "false".
The <activity> element has its own allowTaskReparenting attribute that can override the value set here. See that attribute for more information.
android:backupAgent
The name of the class that implement's the application's backup agent, a subclass of BackupAgent. The attribute value should be a fully qualified class name (such as, "com.example.project.MyBackupAgent"). However, as a shorthand, if the first character of the name is a period (for example, ".MyBackupAgent"), it is appended to the package name specified in the <manifest> element.
There is no default. The name must be specified.
android:debuggable
Whether or not the application can be debugged, even when running on a device in user mode — "true" if it can be, and "false" if not. The default value is "false".
android:description
User-readable text about the application, longer and more descriptive than the application label. The value must be set as a reference to a string resource. Unlike the label, it cannot be a raw string. There is no default value.
android:enabled
Whether or not the Android system can instantiate components of the application — "true" if it can, and "false" if not. If the value is "true", each component's enabled attribute determines whether that component is enabled or not. If the value is "false", it overrides the component-specific values; all components are disabled.
The default value is "true".
android:hasCode
Whether or not the application contains any code — "true" if it does, and "false" if not. When the value is "false", the system does not try to load any application code when launching components. The default value is "true".
An application would not have any code of its own only if it's using nothing but built-in component classes, such as an activity that uses theAliasActivity class, a rare occurrence.
android:hardwareAccelerated
Whether or not hardware-accelerated rendering should be enabled for all Activities and Views in this application — "true" if it should be enabled, and "false" if not. The default value is "false".
Starting from Android 3.0, a hardware-accelerated OpenGL renderer is available to applications, to improve performance for many common 2D graphics operations. When the hardware-accelerated renderer is enabled, most operations in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. This results in smoother animations, smoother scrolling, and improved responsiveness overall, even for applications that do not explicitly make use the framework's OpenGL libraries.
Note that not all of the OpenGL 2D operations are accelerated. If you enable the hardware-accelerated renderer, test your application to ensure that it can make use of the renderer without errors.
android:icon
An icon for the application as whole, and the default icon for each of the application's components. See the individual icon attributes for <activity>,<activity-alias><service><receiver>, and <provider> elements.
This attribute must be set as a reference to a drawable resource containing the image (for example "@drawable/icon"). There is no default icon.
android:killAfterRestore
Whether the application in question should be terminated after its settings have been restored during a full-system restore operation. Single-package restore operations will never cause the application to be shut down. Full-system restore operations typically only occur once, when the phone is first set up. Third-party applications will not normally need to use this attribute.
The default is true, which means that after the application has finished processing its data during a full-system restore, it will be terminated.
android:label
A user-readable label for the application as a whole, and a default label for each of the application's components. See the individual label attributes for<activity><activity-alias><service><receiver>, and <provider> elements.
The label should be set as a reference to a string resource, so that it can be localized like other strings in the user interface. However, as a convenience while you're developing the application, it can also be set as a raw string.
android:logo
A logo for the application as whole, and the default logo for activities.
This attribute must be set as a reference to a drawable resource containing the image (for example "@drawable/logo"). There is no default logo.
android:manageSpaceActivity
The fully qualified name of an Activity subclass that the system can launch to let users manage the memory occupied by the application on the device. The activity should also be declared with an <activity> element.
android:name
The fully qualified name of an Application subclass implemented for the application. When the application process is started, this class is instantiated before any of the application's components.
The subclass is optional; most applications won't need one. In the absence of a subclass, Android uses an instance of the base Application class.
android:permission
The name of a permission that clients must have in order to interact with the application. This attribute is a convenient way to set a permission that applies to all of the application's components. It can be overwritten by setting the permission attributes of individual components.
For more information on permissions, see the Permissions section in the introduction and another document, Security and Permissions.
android:persistent
Whether or not the application should remain running at all times — "true" if it should, and "false" if not. The default value is "false". Applications should not normally set this flag; persistence mode is intended only for certain system applications.
android:process
The name of a process where all components of the application should run. Each component can override this default by setting its own processattribute.
By default, Android creates a process for an application when the first of its components needs to run. All components then run in that process. The name of the default process matches the package name set by the <manifest> element.
By setting this attribute to a process name that's shared with another application, you can arrange for components of both applications to run in the same process — but only if the two applications also share a user ID and be signed with the same certificate.
If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed. If the process name begins with a lowercase character, a global process of that name is created. A global process can be shared with other applications, reducing resource usage.
android:restoreAnyVersion
Indicate that the application is prepared to attempt a restore of any backed-up data set, even if the backup was stored by a newer version of the application than is currently installed on the device. Setting this attribute to true will permit the Backup Manager to attempt restore even when a version mismatch suggests that the data are incompatible. Use with caution!
The default value of this attribute is false.
android:taskAffinity
An affinity name that applies to all activities within the application, except for those that set a different affinity with their own taskAffinity attributes. See that attribute for more information.
By default, all activities within an application share the same affinity. The name of that affinity is the same as the package name set by the<manifest> element.
android:theme
A reference to a style resource defining a default theme for all activities in the application. Individual activities can override the default by setting their owntheme attributes. For more information, see the Styles and Themes developer guide.
android:uiOptions
Extra options for an activity's UI.
Must be one of the following values.
ValueDescription
"none"No extra UI options. This is the default.
"splitActionBarWhenNarrow"Add a bar at the bottom of the screen to display action items in the ActionBar, when constrained for horizontal space (such as when in portrait mode on a handset). Instead of a small number of action items appearing in the action bar at the top of the screen, the action bar is split into the top navigation section and the bottom bar for action items. This ensures a reasonable amount of space is made available not only for the action items, but also for navigation and title elements at the top. Menu items are not split across the two bars; they always appear together.
For more information about the action bar, see the Action Bar developer guide.
This attribute was added in API level 14.
introduced in:
API Level 1
see also:
<activity>
<service>
<receiver>
<provider>

File Conventions

Some conventions and rules apply generally to all elements and attributes in the manifest:
Elements
Only the <manifest> and <application> elements are required, they each must be present and can occur only once. Most of the others can occur many times or not at all — although at least some of them must be present for the manifest to accomplish anything meaningful.
If an element contains anything at all, it contains other elements. All values are set through attributes, not as character data within an element.
Elements at the same level are generally not ordered. For example, <activity><provider>, and <service> elements can be intermixed in any sequence. (An <activity-alias> element is the exception to this rule: It must follow the <activity> it is an alias for.)
Attributes
In a formal sense, all attributes are optional. However, there are some that must be specified for an element to accomplish its purpose. Use the documentation as a guide. For truly optional attributes, it mentions a default value or states what happens in the absence of a specification.
Except for some attributes of the root <manifest> element, all attribute names begin with an android: prefix — for example,android:alwaysRetainTaskState. Because the prefix is universal, the documentation generally omits it when referring to attributes by name.
Declaring class names
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 you define a subclass, as you almost always would for the component classes (ActivityServiceBroadcastReceiver, and ContentProvider), the subclass is declared through a name attribute. The name must include the full package designation. For example, an Service subclass might be declared as follows:
<manifest . . . >
    <application . . . >
        <service android:name="com.example.project.SecretService" . . . >
            . . .
        </service>
        . . .
    </application>
</manifest>
However, as a shorthand, if the first character of the string is a period, the string is appended to the application's package name (as specified by the<manifest> element's package attribute). The following assignment is the same as the one above:
<manifest package="com.example.project" . . . >
    <application . . . >
        <service android:name=".SecretService" . . . >
            . . .
        </service>
        . . .
    </application>
</manifest>
When starting a component, Android creates an instance of the named subclass. If a subclass isn't specified, it creates an instance of the base class.
Multiple values
If more than one value can be specified, the element is almost always repeated, rather than listing multiple values within a single element. For example, an intent filter can list several actions:
<intent-filter . . . >
    <action android:name="android.intent.action.EDIT" />
    <action android:name="android.intent.action.INSERT" />
    <action android:name="android.intent.action.DELETE" />
    . . .</intent-filter>
Resource values
Some attributes have values that can be displayed to users — for example, a label and an icon for an activity. The values of these attributes should be localized and therefore set from a resource or theme. Resource values are expressed in the following format,
@[package:]type:name
where the package name can be omitted if the resource is in the same package as the application, type is a type of resource — such as "string" or "drawable" — and name is the name that identifies the specific resource. For example:
<activity android:icon="@drawable/smallPic" . . . >
Values from a theme are expressed in a similar manner, but with an initial '?' rather than '@':
?[package:]type:name
String values
Where an attribute value is a string, double backslashes ('\\') must be used to escape characters — for example, '\\n' for a newline or '\\uxxxx' for a Unicode character.