AndroidManifest.xml 定义了应用的结构、原数据、组件和权限
根节点manifest
属性 xmlns:android 程序所需的系统属性
属性 versionCode 程序的当前版本号,用以内部比较版本号
属性 versionName 显示给用户的公共版本号
一级子节点: uses-sdk 所使用的SDK版本,包括minimum SDK,maximum SDK,target SDK
示例代码:
一级子节点:
uses-configuration 程序所支持的输入机制的组合
reqFiveWayNav 为true时,程序支持上下左右和确定的导航键
reqHardKeyboard 为true时,程序需要硬件的键盘
reqKeyboardType 键盘类型:nokeys, qwerty, twelvkey, undefined
reqNavigation 导航种类: nonav, dpad, trackball, whell undefined
reqTouchScreen 触摸种类:notouch, stylus, finger, undefined
示例代码:
一级子节点:
uses-feature 指定所用的硬件
一级子节点:
supports-screens
一级子节点:
application
一级子节点:指定权限 uses-permission
一级子节点:permission
一级子节点:测试用 instrumentation
application 子节点
activity
service
provider
receiver
根节点manifest
属性 xmlns:android 程序所需的系统属性
属性 versionCode 程序的当前版本号,用以内部比较版本号
属性 versionName 显示给用户的公共版本号
示例代码:
<manifest xmlns:android=http://schemas.android.com/apk/res/android
package="com.my_domain.my_app"
android:versionCode="1"
android:versionName="0.9 Beta">
[ ... manifest nodes ... ]
</manifest>
一级子节点: uses-sdk 所使用的SDK版本,包括minimum SDK,maximum SDK,target SDK
示例代码:
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="5">
</uses-sdk>
一级子节点:
uses-configuration 程序所支持的输入机制的组合
reqFiveWayNav 为true时,程序支持上下左右和确定的导航键
reqHardKeyboard 为true时,程序需要硬件的键盘
reqKeyboardType 键盘类型:nokeys, qwerty, twelvkey, undefined
reqNavigation 导航种类: nonav, dpad, trackball, whell undefined
reqTouchScreen 触摸种类:notouch, stylus, finger, undefined
示例代码:
<uses-configuration android:reqTouchScreen=["finger"]
android:reqNavigation=["trackball"]
android:reqHardKeyboard=["true"]
android:reqKeyboardType=["qwerty"/>
<uses-configuration android:reqTouchScreen=["finger"]
android:reqNavigation=["trackball"]
android:reqHardKeyboard=["true"]
android:reqKeyboardType=["twelvekey"]/>
一级子节点:
uses-feature 指定所用的硬件
<uses-feature android:glEsVersion=" 0x00010001"
android:name="android.hardware.camera" />
一级子节点:
supports-screens
<supports-screens android:smallScreens=["false"]
android:normalScreens=["true"]
android:largeScreens=["true"]
android:anyDensity=["false"] />
一级子节点:
application
<application android:icon="@drawable/icon"
android:theme="@style/my_theme"
android:name="MyApplication"
android:debuggable="true">
[ ... application nodes ... ]
</application>
一级子节点:指定权限 uses-permission
<uses-permission android:name="android.permission.ACCESS_LOCATION"/>
一级子节点:permission
<permission android:name="com.paad.DETONATE_DEVICE"
android:protectionLevel="dangerous"
android:label="Self Destruct"
android:description="@string/detonate_description">
</permission>
一级子节点:测试用 instrumentation
<instrumentation android:label="My Test"
android:name=".MyTestClass"
android:targetPackage="com.paad.aPackage">
</instrumentation>
application 子节点
activity
<activity android:name=".MyActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<intent-filter>指明启动此activity的Intent
service
<service android:enabled="true" android:name=".MyService"></service>
provider
<provider android:permission="com.paad.MY_PERMISSION"
android:name=".MyContentProvider"
android:enabled="true"
android:authorities="com.paad.myapp.MyContentProvider">
</provider>
receiver
<receiver android:enabled="true"
android:label="My Intent Receiver"
android:name=".MyIntentReceiver">
</receiver>