Android Rookie Learning Note 3----about Androidmainfest.xml

Source: Internet
Author: User

Each Android project contains a Androidmainfest.xml file that contains the nodes that make up every acitivity, Service, Content provider, and broadcast receiver for the application. and use intent Filter and permissions to determine how these components interact with each other and with other applications.

1. root node manifest:

Package properties: The currently applied packages name

Versioncode Property: Defines the version of the current application as an integer that is incremented for each version iteration

Versionname property: Defines a public version number that is displayed to the user

InstallLocation Property: Specifies whether or not the application is allowed (or preferred) to be installed to external storage (usually an SD card). The value can be: preferexternal or auto, using the former, as long as it is possible to install the application on the external storage, the latter is determined by the system. If you do not specify the InstallLocation property, the current app is installed to internal storage and cannot be moved to external storage.

Such as:

<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"

Package= "Cn.csc.mydemo"

Android:versioncode= "1"

Android:versionname= "1.0 Beta"

android:installlocation= "Preferexternal" >

</manifest>

2.manifest Common sub-nodes:

1) USES-SDK:

such as: <USES-SDK

Android:minsdkversion= "10"

Android:targetsdkversion= "/>"

Minsdkversion Property: Specifies the minimum SDK version required by the app, not specified, and defaults to 1

Maxsdkversion Properties: The highest SDK version, it is generally best not to specify, unless you know that the app on the newer version of the platform will definitely not work correctly.

Targetsdkversion properties: Used to specify the version of the platform used in development and testing. Even if the application does not use any new APIs, the target SDK should be set to the latest platform version, which is considered a best practice.

2) Uses-permission:

Configure the permissions required by the application, and when the application is installed, all permissions that are set will be told to the user to decide whether or not to agree to the use of the installation.

such as: <uses-permission android:name= "Android.permission.INTERNET"/> Requires network permissions

3) Instrumentation:

Unit test, use the

such as: <instrumentation

Android:name= "Android.test.InstrumentationTestRunner"

Android:targetpackage= "Cn.csc.demo"/> Specifies the package name to be tested

4) Application:

A mainfest file can have only one application node, and its properties and child nodes are more commonly used

3.application node:

such as: <application

android:icon= "@drawable/ic_launcher"

Android:label= "@string/app_name" >

Icon Property: Specifies the icons for the current application

Label Property: Specifies the title of the current application

1) Activity Sub-node:

<activity

Android:name= ". Mainactivity "

Android:label= "@string/app_name" >

<intent-filter>

<action android:name= "Android.intent.action.MAIN"/>

<category android:name= "Android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

Every activity in the application requires an activity child node that throws a runtime exception when an activity that is not defined in manifest is started. Each activity node allows the Intent-filter child node to be used to define the intent used to initiate the activity.

Name property: Specifies the name of the activity class

2) Service Sub-node: Service used by the application

3) Provider child node: Content Provider used by the application

4) Receiver sub-node: Broadcast receiver used by the reference program

5) Uses-library child node: Used to specify the shared library required by the application

Android Rookie Learning Note 3----about Androidmainfest.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.