[Android Study Notes] 02-androidmanifest.xml File Parsing

Source: Internet
Author: User

Androidmanifest. XML is a file required by each application. It is located in the application root directory, which describesProgramA global variable of the package, including the exposed application components (activities, services, and so on) and the Implementation class of each component, the data that can be operated, and where to run.
An important aspect (concept) of this file is the intent filter. this filter describes when to enable the activity. when an activity (or operating system) wants to execute an action, such as opening a web page or opening a contact selection screen, an intent object is created. this object contains a lot of descriptive information, describing what you want to do, what data you want to process, the data type, and some other important information. android compares the intent information with the intent filter exposed by all applications to find an activity that best processes the data and actions required by the requester. more information about intents is displayed on the intent page.
In addition, you must declare the activities, content providers, services, and intent receivers of your application. You can also specify permissions and instrumentation (security control and test) in the androidmanifest. xml file ).
Example of an androidmanifest. xml file:

 <?  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  > 

Xmlns: the android attribute is an XML namespace declaration statement that tells the android tool to use the public attributes defined in the android namespace. The outermost tag of each android layout file must have this attribute.
In manifest, when multiple activities are defined, how can the system determine which activity is the entry activity when starting this application. Tests show that in the activity defined in manifest, if the action of the activity is the main attribute and the category is the launcher attribute, the activity is the entry program. If there are multiple such activities in manifest, the system uses the activity with the first compound condition found as the entry program. Manifest should contain at least one activity that composite the condition.

Androidmanifest. XML structure outline:

<Manifest> file root node, which describes all contents of the package.
<Uses-Permission> to request a security authorization, you must be granted this permission. Your package can be operated correctly. It can contain zero or more such nodes.
<Permission> declares a Security Authorization policy to restrict which applications can access the components and special mechanisms in your package. It can contain zero or multiple such nodes.
<Instrumentation>
<Application> describes the root node of the application-level component in the package. this node can describe the global (and/or) default attributes of the application, such as labels, icons, themes, required authorizations, and so on. contains zero or one such Node
<Activity> activity is the primary mechanism used for user interaction. when an application is running, the first screen displayed by the user is activity, and the vast majority of other screens (interfaces) used by the user will also be
<Intent-filter>
<Action>
<Category>
<Type>
<Scheme>
<Authority>
<Path>
<Receiver> An intentreceiver allows the application to receive a notification of data changes and behaviors, even if the application is not running. like Activity tags, you can choose to include one or more <intent-filter> elements.
<Service> service is a component that can be run at any time in the background. Like the activity tag, you can choose to include one or more <intent-filter> elements.
<Provider> the contentprovider component is used to manage data persistence and data publishing. published data can be accessed by other applications.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.