Learn Android-----------------------Androidmanifest.xml

Source: Internet
Author: User


Learn Android-----------------------Androidmanifest.xml


in Android, there is a file called Androidmanifest.xml , the file is a global profile developed by the Android project,


End With. Xml. A friend familiar with Java Web development may know that in Web engineering, there is also a global configuration file called XML.


of course Androidmanifest.xml and Web. Xml are similar, we can all configure the relevant configuration of the project in the file (such as initial


Variable settings, Android activity configuration, servlet configuration, etc.).


In general, all of the Android apps that need to be configured need to be configured in the Androidmanifest.xml file, common


Include: Application package name, version number, component, permission information, and so on.



I. Structure of the Androidmanifest.xml file


As an example:


Indicates the version of the XML file and the character encoding <?xml version= "1.0"  encoding= "utf-8"?>//androidmanifest.xml  file to label < Manifest></manifest> is the root node <manifest     //indicates the relevant namespace for Android, usually HTTP// Schemas.android.com/apk/res/android, which makes     //a variety of standard properties in Android can be used in files, providing the data in most elements      xmlns:android= "    //defines the package name of the Java Master application   it is also the default name for an app process      package= "com.example.administrator.myapplication" >    //permission settings, allowing users to read and write contact information     <uses-permission android:name= "Android.permission.READ_CONTACTS"  />     <uses-permission android:name= "Android.permission.WRITE_CONTACTS"  />// A androidmanifest.xml must contain a application tag that declares the components//and attributes of each application (such as icon,label,permission, etc.)      <application        android:allowbackup= "true"          android:icon= "@mipmap/ic_launcher"         android:label= "@string/ App_name "        android:supportsrtl=" true "         android:theme= "@style/apptheme" >        // The definition of android activity         <activity android:name= ". Contactprovider ">        //filter definition, similar to filter  in Java web            <intent-filter>                 <action android:name= " Android.intent.action.MAIN " />                 <category android:name= "Android.intent.category.LAUNCHER"  />              </intent-filter>        </ Activity>    </application></manifest>


Ii. location of Androidmanifest.xml in Android Studio


650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/89/BF/wKiom1gbNXGwXs28AAHeKWWTWV8797.png-wh_500x0-wm_3 -wmp_4-s_775314439.png "title=" Filehelper_1478178130398_28.png "alt=" wkiom1gbnxgwxs28aahekwwtwv8797.png-wh_50 "/ >



Three, androidmanifest.xml commonly used label interpretation



1. Classification


Global Label (package name and version information), component label (four components), permission tag (request and define permissions)


2. Global Label


Package= "Com.example.administrator.myapplication"//define project main function package name, similar to Java application Main method android:revisioncode= "1"// Define the version number of the Android app Android:versionname= "@string/hello"//define the version name of the Android app

The above three attributes are given as attributes in the root tag <manifest >.

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/89/BC/wKioL1gbN_2DzOFIAAAbeVjr_Xw233.png-wh_500x0-wm_3 -wmp_4-s_4104946778.png "title=" Filehelper_1478178788572_39.png "alt=" wkiol1gbn_2dzofiaaabevjr_xw233.png-wh_50 "/ >

<USES-SDK android:minsdkversion= "19"//define the lowest API version android:targetsdkversion= "23"//define Target API version >


3. Component Label


Components tagged with <application></application> tags wrapped, a androidmanifest.xml can contain only one


<application> component nodes, where we can configure relevant component information, such as Android Four components (Activity,


Service, ContentProvider, broadcast Receiver)


For example: Set property values in <application>:


Icon: Android:icon

Title: Android:label

Theme Style: Android:theme



1. The activity component is wrapped by the <activity></activity> tag, and we can specify the Android:name attribute


The class name of the activity, and the value of name is best to fill in the class's fully qualified class name, which is the form of "package name. Class Name".


and initiating any Activity that is not defined in the Androidmanifest.xml file will report the exception accordingly.


<intent-filter></intent-filter> is equivalent to the activity of a card, in real life, we may not know


A thing or a person, but we can determine a person according to the relevant characteristics of the thing, the related deeds of someone, that is <intent-


Filter> corresponds to the activity filter, which defines some characteristics of the activity so that other activity can find it


2. Service

3. Provider need to set the Name property and authorities property

It's the same thing!

This article is from the "@coder" blog, be sure to keep this source http://smallcoder.blog.51cto.com/11941149/1869171

Learn Android-----------------------Androidmanifest.xml

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.