androidmainfest.xml File Explanation
2011-08-12 03:09:17| Category: Android| Report | Font size Subscription
Androidmanifest.xml is a required file for each Android program. It is located at the root of the application, describing the global data in the package, including the components exposed in the package (activities, services, and so on), their respective implementation classes, the various data and boot locations that can be processed.
An important part of this file is the intent-filters it contains. These filters describe where and when the activity started. Whenever an activity (or operating system) is to perform an action, such as opening a Web page or a contact book, it creates an intent object. It can carry some information describing what you want to do, what data you want to process, the type of data, and some other information. Android compares the information in the intent object and each application exposed Intent-filter to find the most appropriate activity to handle the data and actions specified by the caller.
In addition to declaring your program activities, Content Providers, Services, and intent receivers, you can also specify permissions and instrumentation (security control and testing) In the Androidmanifest.xml file.
This is a simple androidmanifest.xml.
< XML version= "1.0" encoding= "Utf-8"?>
< manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "Com.my_domain.app.helloactivity" >
< application android:label= "@string/app_name" >
< activity class= ". Helloactivity ">
< intent-filter>
< action android:value= "Android.intent.action.MAIN"/>
< category android:value= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
It is worth mentioning some of the most common:
· Almost all of the androidmanifest.xml (and many other Android XML files) contained the namespace declaration xmlns:android= "Http://schemas.android.com/apk/res/android" in the first element. This allows the various standard properties in Android to be used in the file, providing the data in most of the elements.
· Most manifests contain a single < application> element that defines all application-level components and attributes and can be used in the package.
· Any package that is considered a top-level application by the user and can be used by the program launcher needs to contain at least one activity component to support the main operation and the launcher kind, as seen in the code above.
Here is a detailed list of the structure of the Androidmanifest.xml file that describes all the tags that can be used.
Manifest
Root node, which describes all the contents of the package. Under it can be placed:
Uses-permission
Ask for the security license you need to give your package a normal operation. See Securitymodel For more information on licensing. A manifest can contain 0 or more of this element.
Permission
A security license is declared to limit which programs can be components and features in your package. See Securitymodel For more information on licensing. A manifest can contain 0 or more of this element.
Instrumentation
The code that is used to test this package or other Packages directive component is declared. See instrumentation for more information on licensing. A manifest can contain 0 or more of this element.
Application
Contains the root node of the application level component declaration in the package. This element can also contain global and default attributes in application, such as tags, icons, themes, necessary permissions, and so on. A manifest can contain 0 or one of this element (no extra one is allowed). Under it can place 0 or more of the following component declarations:
Activity
Activity is the primary tool for interacting with users. When a user opens an application's initial page, an activity, most of the other pages used is also implemented by different activity and declared in another activity tag.
Note: Each activity must have a < activity> tag, whether it is used externally or only in its own package. If an activity does not have a corresponding tag, you will not be able to run it.
In addition, to support the runtime to find your activity late, you can include one or more < intent-filter> elements to describe the actions your activity supports:
Intent-filter
Declares a intent value supported by a specified set of components, thus forming a intentfilter. In addition to being able to specify different types of values under this element, attributes can also be placed here to describe the unique label, icon, and other information required for an operation.
Action
The intentaction that the component supports.
Category
The intentcategory that the component supports.
Type
The Intentdata MIME type supported by the component.
Schema
The Intentdata URI scheme supported by the component.
Authority
The Intentdata URI authority supported by the component.
Path
The Intentdata URI path supported by the component.
Receiver
Intentreceiver enables the application to obtain data changes or actions that occur even if it is not currently running. With the activity tag, you can optionally include one or more of the < intent-filter> elements supported by receiver;
Service
A service is a component that can run at any time in the background. With the activity tag, you can optionally include one or more of the < intent-filter> elements supported by receiver;
Provider
ContentProvider is a component used to manage persisted data and publish it to other applications. Androidmanifest.xml is a required file for each Android program. It is located at the root of the application, describing the global data in the package, including the components exposed in the package (activities, services, and so on), their respective implementation classes, the various data and boot locations that can be processed.
Androidmainfest.xml file Explanation