Android Development Learning Note (a)-manifest file

Source: Internet
Author: User

One: Overview

All apps are androidmanifest.xml files in the root directory, which shows the basic information that the app tells the Android system. The Android system obtains basic information from this file before the app code is run

Function:

    1. The Java wrap masterpiece for the app is the unique identifier for this app
    2. Declaring the components to be used in the app
    3. Decide which processes hold app components
    4. Determine the user rights required by the app
    5. It declares what permissions the application must have to access the protected portions of the API and interact with other applications
    6. It declares what permissions the application must have to access the protected portions of the API and interact with other applications
    7. Declare the minimum level required by the app
    8. Declaring the app requires a link to the API library (in addition to the Android API framework)

II: Structure of the manifest file

1 <?XML version= "1.0" encoding= "Utf-8"?>2 3 <Manifest>4 5     <uses-permission/>6     <Permission/>7     <Permission-tree/>8     <Permission-group/>9     <Instrumentation/>Ten     <USES-SDK/> One     <uses-configuration/>   A     <uses-feature/>   -     <Supports-screens/>   -     <Compatible-screens/>   the     <supports-gl-texture/>   -  -     <Application> -  +         <Activity> -             <Intent-filter> +                 <Action/> A                 <category/> at                 <Data/> -             </Intent-filter> -             <Meta-data/> -         </Activity> -  -         <Activity-alias> in             <Intent-filter>. . .</Intent-filter> -             <Meta-data/> to         </Activity-alias> +  -         <Service> the             <Intent-filter>. . .</Intent-filter> *             <Meta-data/> $         </Service>Panax Notoginseng  -         <receiver> the             <Intent-filter>. . .</Intent-filter> +             <Meta-data/> A         </receiver> the  +         <provider> -             <grant-uri-permission/> $             <Meta-data/> $             <path-permission/> -         </provider> -  the         <uses-library/> - Wuyi     </Application> the  - </Manifest>

Three: Manifest file conventions

Element

Each of the manifest files must appear once <manifest> and <application> elements, and other elements are determined to appear once, multiple, or once, depending on the function needs.

All values are set by property and are not used as character data within the element.

Elements of the same level are ordered in random order. (The <activity-alias> element is an exception, it must follow the <activity> behind which it refers.) )

Attribute:

In a formal sense, the attributes of each element are optional, but in the premise of completing a function, the attribute values of some elements must be described, using the document as a guideline. For a truly optional property, it mentions a default value or tells what happens when the specification is missing.

In addition to the attribute values of the root element <manifest>, all other attribute values must android: begin with a prefix, because the prefixes are generic concepts, so the document usually ignores the property when it is referenced by name

declaring class names:

Some elements are equivalent to Java objects, including <application> and four components <activity>, <service>, <receiver>, <provider>

If you want to define a subclass of a component class, the declaration of this subclass is through the Name property, and the Name property includes the full package name

1 <Manifest. . . >2     <Application. . . >3         <ServiceAndroid:name= "Com.example.project.SecretService" . . . >4             . . .5         </Service>6         . . .7     </Application>8 </Manifest>

However, as shorthand. If the first character of a string is ".", the string will be added to the end of the app's package name

1 <Manifest Package= "Com.example.project" . . . >2     <Application. . . >3         <ServiceAndroid:name=". Secretservice " . . . >4             . . .5         </Service>6         . . .7     </Application>8 </Manifest>

When you start a component, Android creates a subclass of the object, and if the subclass is unspecified, it creates a base class

Multiple Values:

If you specify more than one value, you typically repeat the element to specify a value instead of listing multiple values in an element cell

<Intent-filter. . . >    <ActionAndroid:name= "Android.intent.action.EDIT" />    <ActionAndroid:name= "Android.intent.action.INSERT" />    <ActionAndroid:name= "Android.intent.action.DELETE" />    . . .</Intent-filter>

Resource Values:

Some resources have values displayed to the user, such as a label or icon for the activity, which should be localized and therefore set to come from the same resource or topic.

Resource values are expressed in the following format

1 @[package:]type:name

Package: When a resource is in the same bundle in the app, the packages value can be defaulted

Type: Types of resources, such as String, drawable

Name: is a name used to specify a special resource.

1 <activity android:icon= "@drawable/smallpic" ... >

The subject value is expressed in the following format

1 ? [Package:]type:name

String Values:

When the property value is a string, the escape character is added "\ \". For example, ' \\n ' is used as a carriage return or ' \\uxxxx ' as a Unicode character.

Android Development Learning Note (a)-manifest file

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.