Android 开发文档 程序基础——The manifest file
2010-06-19 10:52
393 查看
android开始运行一个程序组件之前,会先确定这个组件的存在。因此,程序会在打包在apk中的manifest文件中声明组件,apk文
件中同时也有代码,文件和资源。
manifest是xml文件,在所有的程序中都命名为AndroidManifest.xml。除了声明程序组件之外,还做一些其他的事情,例如
命名程序需要链接的库,确认程序希望被授予的权限。
不过最主要的任务还是告诉android有关程序的组件。例如:
<?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>
没有在manifest文件中声明的组件在系统中不可见,因此
也不会运行。但是broadcast
receiver不但可以在manifest中声明,也可以在代码中动态创建,通过调用Context.registerReceiver()来注册到系
统中。
转自我的android博客
原文
that the component exists. Therefore, applications declare their
components in a manifest file that’s bundled into the Android package,
the .apk
file that also
holds the application’s code, files, and resources.
The manifest is a structured XML file and is always named
AndroidManifest.xml for all applications. It does a number of things in
addition to declaring the application’s components, such as naming any
libraries the application needs to be linked against (besides the
default Android library) and identifying any permissions the application
expects to be granted.
But the principal task of the manifest is to inform Android about
the application’s components. For example, an activity might be
declared as follows:
<?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>
The name
attribute of
the <activity>
element names the Activity
subclass that implements the activity. The icon
and label
attributes point to resource files containing an icon and label that
can be displayed to users to represent the activity.
The other components are declared in a similar way — <service>
elements for
services, <receiver>
elements for broadcast receivers, and <provider>
elements for content providers.
Activities, services, and content providers that are not declared in
the manifest are not visible to the system and are consequently never
run. However, broadcast receivers can either be declared in the
manifest, or they can be created dynamically in code (as BroadcastReceiver
objects) and
registered with the system by calling Context.registerReceiver()
.
For more on how to structure a manifest file for your application,
see The AndroidManifest.xml File.
件中同时也有代码,文件和资源。
manifest是xml文件,在所有的程序中都命名为AndroidManifest.xml。除了声明程序组件之外,还做一些其他的事情,例如
命名程序需要链接的库,确认程序希望被授予的权限。
不过最主要的任务还是告诉android有关程序的组件。例如:
<?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>
没有在manifest文件中声明的组件在系统中不可见,因此
也不会运行。但是broadcast
receiver不但可以在manifest中声明,也可以在代码中动态创建,通过调用Context.registerReceiver()来注册到系
统中。
转自我的android博客
原文
The manifest file
Before Android can start an application component, it must learnthat the component exists. Therefore, applications declare their
components in a manifest file that’s bundled into the Android package,
the .apk
file that also
holds the application’s code, files, and resources.
The manifest is a structured XML file and is always named
AndroidManifest.xml for all applications. It does a number of things in
addition to declaring the application’s components, such as naming any
libraries the application needs to be linked against (besides the
default Android library) and identifying any permissions the application
expects to be granted.
But the principal task of the manifest is to inform Android about
the application’s components. For example, an activity might be
declared as follows:
<?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>
The name
attribute of
the <activity>
element names the Activity
subclass that implements the activity. The icon
and label
attributes point to resource files containing an icon and label that
can be displayed to users to represent the activity.
The other components are declared in a similar way — <service>
elements for
services, <receiver>
elements for broadcast receivers, and <provider>
elements for content providers.
Activities, services, and content providers that are not declared in
the manifest are not visible to the system and are consequently never
run. However, broadcast receivers can either be declared in the
manifest, or they can be created dynamically in code (as BroadcastReceiver
objects) and
registered with the system by calling Context.registerReceiver()
.
For more on how to structure a manifest file for your application,
see The AndroidManifest.xml File.
相关文章推荐
- Android 开发文档 之程序基础Application Fundamentals
- Android开发——Package is not specified in the manifest file
- Android 开发文档 程序基础 ——activity组件
- Android 开发文档 程序基础 ——Services组件
- Android 开发文档 程序基础——Activities and Tasks
- Android开发基础——真机测试错误,ADB启动不了,程序安装不了,the connection to adb is down,INSTALL_CANCELED_BY_USER...
- Android 开发文档 程序基础 ——Broadcast receivers组件
- Android 开发文档 程序基础 ——Content providers组件
- Android 开发文档 程序基础——Affinities and new tasks
- Android 开发文档 程序基础——Activating components: intents
- Android 开发文档 程序基础——Shutting down components
- Android 开发文档 程序基础——Intent filters
- Android开发 Error:The number of method references in a .dex file cannot exceed 64K.
- Eclipse开发Java和Android程序:配置文档提示和源代码查看功能(doc和source)
- Could not find the AndroidManifest.xml file,...found usingdummy file [file:///home/malachi/work/Anno
- Android 程序开发——百度地图的使用(一) 基础配置
- Android程序开发0基础教程(一)
- Android 程序开发——百度地图的使用(二) 基础地图
- [置顶] JAVA中 错误代码是 the public type must be defined in its own file 解决方法 android开发 java编程
- Android开发之道(4)程序框架基础