The manifest file
Android启动应用程序组件之前,首先必须知道被启动的应用中都有哪些组件.所以应用程序需要在manifest文件中声明该应用都绑定了什么组件, 在应用程序对应的.apk文件中同时也包含了应用程序代码、文件以及相关的资源。
manifest是一个 XML 文件,总是被命名为AndroidManifest.xml,其中,并非仅仅是声明组件,同时该文件中还可能指定该应用所需的类库以及该应用希望被授权的许可。
但是该文件的最主要作用是告知Android系统该应用所关联的组件信息例如:一个activity可以用下面的方式在AndroidManifest.xml中被声明:
<?xml version="1.0" encoding="utf-8"?>
<manifest . . . >
<application . . . >
<activity android:name="com.example.project.FreneticActivity"
android:icon="@drawable/small_pic.png"
android:label="@string/freneticLabel"
. . . >
</activity>
. . .
</application>
</manifest>
其中,activity元素的 name 属性声明了该activity类的实现类,icon 属性和 label 属性指定了 该应用所关联的资源文件中约定的icon 和 label信息.
其他组件的声明和以上类似 — <service> 元素用来声明 services组件, <receiver> 元素用来声明 broadcast receivers组件, <provider> 元素用来声明 content providers组件. 没有在AndroidManifest.xml文件中声明的Activities, services, 和 content providers 组件对于系统来说是不可见的,不会被运行的。但是, broadcast receivers是个特例,它可以在AndroidManifest.xml文件中声明也可以以代码方式动态创建 (as BroadcastReceiver objects) 然后通过 Context.registerReceiver()方法注册到Android系统中.
For more on how to structure a manifest file for your application, see The AndroidManifest.xml File.
Android启动应用程序组件之前,首先必须知道被启动的应用中都有哪些组件.所以应用程序需要在manifest文件中声明该应用都绑定了什么组件, 在应用程序对应的.apk文件中同时也包含了应用程序代码、文件以及相关的资源。
manifest是一个 XML 文件,总是被命名为AndroidManifest.xml,其中,并非仅仅是声明组件,同时该文件中还可能指定该应用所需的类库以及该应用希望被授权的许可。
但是该文件的最主要作用是告知Android系统该应用所关联的组件信息例如:一个activity可以用下面的方式在AndroidManifest.xml中被声明:
<?xml version="1.0" encoding="utf-8"?>
<manifest . . . >
<application . . . >
<activity android:name="com.example.project.FreneticActivity"
android:icon="@drawable/small_pic.png"
android:label="@string/freneticLabel"
. . . >
</activity>
. . .
</application>
</manifest>
其中,activity元素的 name 属性声明了该activity类的实现类,icon 属性和 label 属性指定了 该应用所关联的资源文件中约定的icon 和 label信息.
其他组件的声明和以上类似 — <service> 元素用来声明 services组件, <receiver> 元素用来声明 broadcast receivers组件, <provider> 元素用来声明 content providers组件. 没有在AndroidManifest.xml文件中声明的Activities, services, 和 content providers 组件对于系统来说是不可见的,不会被运行的。但是, broadcast receivers是个特例,它可以在AndroidManifest.xml文件中声明也可以以代码方式动态创建 (as BroadcastReceiver objects) 然后通过 Context.registerReceiver()方法注册到Android系统中.
For more on how to structure a manifest file for your application, see The AndroidManifest.xml File.
发表评论
-
Intents and Intent Filters--Intent filters
2010-09-03 10:21 1368Intent filters To inform ... -
Intents and Intent Filters---Intent Resolution
2010-09-03 09:45 1201Intent Resolution Intents 可以分成 ... -
Intents and Intent Filters---Intent Objects
2010-09-02 11:15 821Intent Objects An Intent ... -
Intents and Intent Filters---序言
2010-09-01 16:06 879Intents and Intent Filters Key ... -
Application Fundamentals--Processes and lifecycles(进程生命周期)
2010-08-30 09:23 762Processes and lifecycles---进 ... -
Application Fundamentals--Broadcast receiver lifecycle(广播接收组件生命周期)
2010-08-30 09:20 4250Broadcast receiver lifecycle--- ... -
Application Fundamentals--Service lifecycle(服务组件的生命周期)
2010-08-30 09:18 1054Service lifecycle--服务组件的生命周期 A ... -
Application Fundamentals--Coordinating activities(activity实例间协调)
2010-08-30 09:15 972Coordinating activities---activ ... -
Application Fundamentals--Saving activity state(保存activity实例的状态信息)
2010-08-27 10:06 1262Saving activity state--保存activi ... -
Application Fundamentals--Component Lifecycles(组件生命周期)
2010-08-27 09:56 964Component Lifecycles--组件生命周期 A ... -
Application Fundamentals--Thread-safe methods(线程安全方法)
2010-08-27 09:51 1259Thread-safe methods--线程安 ... -
Application Fundamentals--Remote procedure calls(远程过程调用)
2010-08-27 09:41 1300Remote procedure calls--远程过程调用 ... -
Application Fundamentals--Processes and Threads(进程与线程)
2010-08-27 09:36 996Processes and Threads--进程 ... -
Application Fundamentals--Starting tasks
2010-08-27 09:34 704Starting tasks An activity is ... -
Application Fundamentals--Clearing the stack(堆栈清理)
2010-08-27 09:28 1351Clearing the stack--堆栈清理 If th ... -
Application Fundamentals--Launch modes-启动模式
2010-08-27 09:27 1120Launch modes-启动模式 There are fo ... -
Application Fundamentals--Affinities and new tasks
2010-08-27 08:45 983Affinities and new tasks By de ... -
Application Fundamentals--Activities and Tasks
2010-08-27 08:42 794Activities and Tasks As noted ... -
Application Fundamentals--Intent 过滤器
2010-08-27 08:41 926Intent 过滤器 Intent 对象可以显式指定目标组件 ... -
Application Fundamentals--Activating components: intents(组件的激活)
2010-08-27 08:38 937Activating components: intents- ...
相关推荐
Introducing the Application Manifest File Using the Manifest Editor Externalizing Resources The Android Application Lifecycle Understanding an Application's Priority and Its Process' States ...
Some Final Comments on the MOV Instructions <br>4.9 Laboratory Exercises 4.9.1 The UCR Standard Library for 80x86 Assembly Language Programmers 4.9.2 Editing Your Source Files 4.9.3 The ...
应用程序基础Application Fundamentals 4 关键类 4 应用程序组件 5 激活组件:intent 7 关闭组件 7 manifest文件 8 Intent过滤器 8 Activity和任务 10 Affinity(吸引力)和新任务 11 加载模式 12 清理堆栈 13 启动...
应用程序基础Application Fundamentals 4 关键类 4 应用程序组件 5 激活组件:intent 7 关闭组件 7 manifest文件 8 Intent过滤器 8 Activity和任务 10 Affinity(吸引力)和新任务 11 加载模式 12 清理...
应用程序基础Application Fundamentals 4 关键类 4 应用程序组件 5 激活组件:intent 7 关闭组件 7 manifest文件 8 Intent过滤器 8 Activity和任务 10 Affinity(吸引力)和新任务 11 加载模式 12 清理堆栈 13 启动...
Fundamentals 171 Introduction 172 Variables 173 Constants 175 Structures 176 Program Flow Control 178 If…Then…Else 178 Select Case 182 While Loops 184 For Loops 186 Arrays 187 Declaring ...
应用程序基础Application Fundamentals................................ 4 关键类................................................................ 4 应用程序组件...............................................