The AndroidManifest.xml File

http://www.cnblogs.com/gcg0036/p/4320738.html

<?xml version="1.0" encoding="utf-8"?>

<manifest>

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration />  
    <uses-feature />  
    <supports-screens />  
    <compatible-screens />  
    <supports-gl-texture />  

    <application>

        <activity>
            <intent-filter>
                <action />
                <category />
                <data />
            </intent-filter>
            <meta-data />
        </activity>

        <activity-alias>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </activity-alias>

        <service>
            <intent-filter> . . . </intent-filter>
            <meta-data/>
        </service>

        <receiver>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </receiver>

        <provider>
            <grant-uri-permission />
            <meta-data />
            <path-permission />
        </provider>

        <uses-library />

    </application>

</manifest>

只有<manifest>和<application>元素是必须的,而且只能出现一次。

元素不能包含自己,所有的值都必须通过属性设置,而不是元素中的字符。

除了<manifest>根元素的某些属性,其他所有的属性都以 android:为前缀——例如,android:alwaysRetainTaskState。
因为前缀是通用的,所以当引用属性的名字的时候本文档会自动将其忽略。

如果定义一个子类,比如用户通常会定义的组件子类(Activity,Service,BroadcastReceiver,ContentProvider),通常由name属性声明。
这个名字必须包括完整的包名。
但是,作为简写,如果字符串的第一个字符为一个点,那么字符串将会被添加到应用程序的包名(由manifest的package属性指定)之后

<manifest . . . >
    <application . . . >
        <service android:name="com.example.project.SecretService" . . . >
            . . .
        </service>
        . . .
    </application>
</manifest>
<manifest package="com.example.project" . . . >
    <application . . . >
        <service android:name=".SecretService" . . . >效果同上
            . . .
        </service>
        . . .
    </application>
</manifest>

某些属性的值可以展示给用户看——例如,活动的标签和图标。这些属性的值应该本地化,因此可以从一个资源或主题中获取。
资源值通常按以下格式表示, @[package:]type:name
其中,如果资源跟应用程序在同一个包中,那么包名可以省略。
type是资源的类型——例如“string”或者“drawable”——
name是识别具体资源的标识。例如:

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

从主题中获取的值可以用类似的方法表示,只不过首字符使用而不是@:
?[package:]type:name

当属性值是一个字符串的时候,需要使用双反斜杠('\\')来转义字符——例如'\\n'代表换行,或者'\\uxxxx'代表Unicode字符。

 

任何情况下,在容器元素中设定的图标和标签,将会成为其子元素的默认图标和标签。因此,在application元素中设定的图标和标签,将会是应用程序中每个组件的默认设置。类似的,组件的图标和标签——例如,activity元素——将会是该组件的每一个intent-filter元素的默认设置。如果application元素设置了一个标签,但是activity和intent过滤器没有设置,那么应用程序标签将同时适用于activity和intent过滤器。

不管组件何时展现给用户,intent过滤器设置的图标和标签都代表实现该过滤器功能的组件。 例如,设置了“android.intent.action.MAIN”和“android.intent.category.LAUNCHER”的过滤器代表了由这个activity来启动应用程序——也就是说,应用程序启动的时候,这个activity最先显示。因此,启动画面显示的图标和标签就是过滤器中设置的图标和标签。

 

如果应用程序需要访问有权限保护的特性,必须在manifest中用<uses-permission>元素声明该应用程序需要使用该权限。

或者应用程序也可以定义自己的权限。新的权限通过<permission>元素声明。例如,可以按照以下方法保护activity:

<manifest . . . >
    <permission android:name="com.example.project.DEBIT_ACCT" . . . />
    <uses-permission android:name="com.example.project.DEBIT_ACCT" />
    . . .
    <application . . .>
        <activity android:name="com.example.project.FreneticActivity"
                  android:permission="com.example.project.DEBIT_ACCT"
                  . . . >
            . . .
        </activity>
    </application>
</manifest>

注意,在这个例子中,DEBIT_ACCT权限不仅使用<permission>元素声明,同时也需要使用<uses-permission>声明。应用程序的其他组件想要运行被保护的activity的时候,就需要使用该权限,即使该activity是被应用程序本身保护的。

还是这个例子,如果permission属性已经在其他地方声明过了(比如android.permission.CALL_EMERGENCY_NUMBERS中),那么就无需再用<permission>元素声明了,但是<uses-permission>元素的声明还是需要的。

 

每一个应用程序都会连接到android的默认库,这个库中包含了编译应用程序需要的基础包(包中含有常用的类,如Activity, Service, Intent, View, Button, Application, ContentProvider等)。
但是,有些包有自己的库。如果应用程序要使用这些包中的代码,就必须显式地链接这些包的库。在manifest文件中必须包含独立的<uses-library>元素,将需要的库全部列举出来

 

<manifest xmlns:android=http://schemas.android.com/apk/res/android 固定不变
              package="string" 全路径,一旦发布则不能更改,否则会成为新程序,无法更新版本
              android:sharedUserId="string"
              android:sharedUserLabel="string resource" 
              android:versionCode="integer"
              android:versionName="string"
              android:installLocation=["auto" | "internalOnly" | "preferExternal"] >安装位置
    </manifest>

http://www.cnblogs.com/popapa/p/android_manifest-element.html

AndroidManifest.xml 文件的根元素。 必须包含 <application> 元素且设定 xmlns:android 和 package 属性。

安装位置:http://wiki.eoeandroid.com/App_Install_Location

 

<application android:allowTaskReparenting=["true" | "false"]
                 android:allowBackup=["true" | "false"]
                 android:backupAgent="string"
                 android:debuggable=["true" | "false"] 应用程序能否被调试,即使是以用户模式运行在设备中——“true”表示可以,“false”表示不允许。默认值是“false”。
                 android:description="string resource"
                 android:enabled=["true" | "false"]
                 android:hasCode=["true" | "false"]
                 android:hardwareAccelerated=["true" | "false"]
                 android:icon="drawable resource"
                 android:killAfterRestore=["true" | "false"]
                 android:largeHeap=["true" | "false"]
                 android:label="string resource"
                 android:logo="drawable resource"
                 android:manageSpaceActivity="string"
                 android:name="string"
                 android:permission="string"
                 android:persistent=["true" | "false"]
                 android:process="string"
                 android:restoreAnyVersion=["true" | "false"]
                 android:requiredAccountType="string"
                 android:restrictedAccountType="string"
                 android:supportsRtl=["true" | "false"]
                 android:taskAffinity="string"
                 android:testOnly=["true" | "false"]
                 android:theme="resource or theme"
                 android:uiOptions=["none" | "splitActionBarWhenNarrow"]
                 android:vmSafeMode=["true" | "false"] >
        . . .
    </application>

http://www.cnblogs.com/popapa/p/android_application-element.html

对应用程序的声明。

 

<activity android:allowTaskReparenting=["true" | "false"]
              android:alwaysRetainTaskState=["true" | "false"]
              android:clearTaskOnLaunch=["true" | "false"]
              android:configChanges=["mcc", "mnc", "locale",
                                     "touchscreen", "keyboard", "keyboardHidden",
                                     "navigation", "screenLayout", "fontScale", "uiMode",
                                     "orientation", "screenSize", "smallestScreenSize"]
              android:enabled=["true" | "false"]
              android:excludeFromRecents=["true" | "false"]
              android:exported=["true" | "false"]
              android:finishOnTaskLaunch=["true" | "false"]
              android:hardwareAccelerated=["true" | "false"]
              android:icon="drawable resource"
              android:label="string resource"
              android:launchMode=["multiple" | "singleTop" |
                                  "singleTask" | "singleInstance"] 默认模式是standard。
              android:multiprocess=["true" | "false"]
              android:name="string"
              android:noHistory=["true" | "false"]  
              android:parentActivityName="string" 
              android:permission="string"
              android:process="string"
              android:screenOrientation=["unspecified" | "behind" |
                                         "landscape" | "portrait" |
                                         "reverseLandscape" | "reversePortrait" |
                                         "sensorLandscape" | "sensorPortrait" |
                                         "userLandscape" | "userPortrait" |
                                         "sensor" | "fullSensor" | "nosensor" |
                                         "user" | "fullUser" | "locked"]
              android:stateNotNeeded=["true" | "false"]
              android:taskAffinity="string"
              android:theme="resource or theme"
              android:uiOptions=["none" | "splitActionBarWhenNarrow"]
              android:windowSoftInputMode=["stateUnspecified",
                                           "stateUnchanged", "stateHidden",
                                           "stateAlwaysHidden", "stateVisible",
                                           "stateAlwaysVisible", "adjustUnspecified",
                                           "adjustResize", "adjustPan"] >   
        . . .
    </activity>

http://www.cnblogs.com/popapa/p/android_activity-element.html

所有的Activity需要在manifest文件里通过<acctivity>声明,否则不可以被显示也不会运行。

启动模式:http://www.cnblogs.com/popapa/p/android_tasks-and-back-stack.html

样式与主题:http://wiki.eoeandroid.com/Styles_and_Themes

权限:http://www.cnblogs.com/popapa/p/android_permissions.html

Action Bar:http://wiki.eoeandroid.com/Action_Bar

 

<intent-filter android:icon="drawable resource"
                   android:label="string resource"
                   android:priority="integer" >
    ..
    </intent-filter>

http://www.cnblogs.com/popapa/p/android_intent-filter-element.html

声明了其父组件的功能 — Activity 或 Service 可完成的功能以及 Receiver 可处理的广播类型。

必须包含一个或多个 <action> 元素。 如果其中没有包含任何 <action> 元素,则过滤器不会收到任何 Intent 对象。

以“android.intent.action.”作为前缀,加在 ACTION_ 后的 string 前面。 例如,对于 ACTION_MAIN 而言,用“android.intent.action.MAIN

对于自定义的 Action ,最好用包名作前缀,以确保唯一性。

http://wiki.eoeandroid.com/Intents_and_Intent_Filters

action:http://www.cnblogs.com/popapa/p/android_action-element.html

catelory:http://www.cnblogs.com/popapa/p/android_category-element.html

data:http://www.cnblogs.com/popapa/p/android_data-element.html

posted @ 2015-03-07 18:03  gcg0036  阅读(253)  评论(0编辑  收藏  举报