Androidmanifest. XML is a required file in every android program. It is located in the root directory of the application and describes global data in the package, including components exposed in the package (activities, services, and so on), their respective implementation classes, various data and startup locations that can be processed.
An important part of this file is its intent-filters. These filters describe the start position and time of the activity. Every time an activity (or operating system) needs to perform an operation, such as opening a webpage or contact book, it creates an intent object. It can carry information that describes what you want to do, what data you want to process, the data type, and some other information. Android compares the information in the intent-filter exposed by the intent object and each application to find the most suitable activity to process the data and operations specified by the caller. For more information about intent, visit the intent reference page.
In addition to declaring activities, content providers, services, and intent receivers in your program, you can also specify permissions and instrumentation (Security Control and testing) in the androidmanifest. xml file. See androidmanifest tag and attribute reference.
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 common features:
- Almost all AndroidManifest. xml (and many other Android xml files) contains the namespace statement xmlns: android = "http://schemas.android.com/apk/res/android" in the first element ". In this way, various standard attributes in Android can be used in files and data in most elements is provided.
- Most manifests contain a single <application> element, which defines all application-level components and attributes and can be used in a package.
- Any package that is considered as a top-level application and can be used by the program initiator must contain at least one Activity component to support the MAIN operation and LAUNCHER type, as shown in the above Code.
Here is a detailed list of AndroidManifest. xml file structures, describing all the tags that can be used.
Manifest
The root node that describes all contents of the package. Under it, you can place:
Uses-permission
Request the security license required for the normal operation of your package. See the Security Model for more information. A manifest can contain zero or more elements.
Permission
Declares a security license to limit which programs can be used for components and functions in your package. See the Security Model for more information. A manifest can contain zero or more elements.
Instrumentation
Declared code used to test this package or other package command components. See Instrumentation for more information on licensing. A manifest can contain zero or more elements.
Application
The root node that contains the application-level component declaration in the package. This element can also contain global and default attributes in the application, such as tags, icons, topics, necessary permissions, and so on. A manifest can contain zero or one such element (no additional one is allowed ). Under it, zero or more of the following component declarations can be placed:
Activity
Activity is the main tool used to interact with users. When a user opens an initial page of an application, most of the other pages used are implemented by different activities and declared in another activity tag.
Note: Each activity must have a <activity> tag, whether used externally or only in its own package. If an activity has no corresponding tag, you cannot run it.
In addition, to support searching for your activity later than running, you can include one or more <intent-filter> elements to describe the operations supported by your activity:
Intent-Filter
Declares the intent values supported by a specified group of parts to form an intentfilter. In addition to specifying different types of values under this element, attributes can also be placed here to describe the unique tag, icon and other information required for an operation.
Action
Intent action supported by the component.
Category
Intent category supported by the component.
Type
Intent data MIME type supported by the component.
Schema
Intent data URI scheme supported by the component.
Authority
The Intent data URI authority supported by the component.
Path
Intent data URI path supported by the component.
Cycler
Intentreceiver allows the application to obtain data changes or operations, even if it is not currently running. With activity tags, You can selectively include the <intent-filter> elements supported by one or more referers;
Service
Service is a component that can run at any time in the background. With activity tags, You can selectively include the <intent-filter> elements supported by one or more referers;
Provider
Contentprovider is a component used to manage persistent data and publish it to other applications.