博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AndroidManifest File Features
阅读量:6486 次
发布时间:2019-06-23

本文共 6218 字,大约阅读时间需要 20 分钟。

http://www.android-doc.com/guide/topics/manifest/manifest-intro.html

The following sections describe how some Android features are reflected in the manifest file.

Intent Filters

The core components of an application (its activities, services, and broadcast receivers) are activated by intents. An intent is a bundle of information (an  object) describing a desired action — including the data to be acted upon, the category of component that should perform the action, and other pertinent instructions. Android locates an appropriate component to respond to the intent, launches a new instance of the component if one is needed, and passes it the Intent object.

Components advertise their capabilities — the kinds of intents they can respond to — through intent filters. Since the Android system must learn which intents a component can handle before it launches the component, intent filters are specified in the manifest as  elements. A component may have any number of filters, each one describing a different capability.

An intent that explicitly names a target component will activate that component; the filter doesn't play a role. But an intent that doesn't specify a target by name can activate a component only if it can pass through one of the component's filters.

For information on how Intent objects are tested against intent filters, see a separate document, .

Icons and Labels

A number of elements have icon and label attributes for a small icon and a text label that can be displayed to users. Some also have a description attribute for longer explanatory text that can also be shown on-screen. For example, the  element has all three of these attributes, so that when the user is asked whether to grant the permission to an application that has requested it, an icon representing the permission, the name of the permission, and a description of what it entails can all be presented to the user.

In every case, the icon and label set in a containing element become the default icon and label settings for all of the container's subelements. Thus, the icon and label set in the  element are the default icon and label for each of the application's components. Similarly, the icon and label set for a component — for example, an  element — are the default settings for each of the component's elements. If an  element sets a label, but an activity and its intent filter do not, the application label is treated as the label for both the activity and the intent filter.

The icon and label set for an intent filter are used to represent a component whenever the component is presented to the user as fulfilling the function advertised by the filter. For example, a filter with "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" settings advertises an activity as one that initiates an application — that is, as one that should be displayed in the application launcher. The icon and label set in the filter are therefore the ones displayed in the launcher.

Permissions

permission is a restriction limiting access to a part of the code or to data on the device. The limitation is imposed to protect critical data and code that could be misused to distort or damage the user experience. 

Each permission is identified by a unique label. Often the label indicates the action that's restricted. For example, here are some permissions defined by Android:

android.permission.CALL_EMERGENCY_NUMBERS 

android.permission.READ_OWNER_DATA 
android.permission.SET_WALLPAPER 
android.permission.DEVICE_POWER

A feature can be protected by at most one permission.

If an application needs access to a feature protected by a permission, it must declare that it requires that permission with a  element in the manifest. Then, when the application is installed on the device, the installer determines whether or not to grant the requested permission by checking the authorities that signed the application's certificates and, in some cases, asking the user. If the permission is granted, the application is able to use the protected features. If not, its attempts to access those features will simply fail without any notification to the user. 

An application can also protect its own components (activities, services, broadcast receivers, and content providers) with permissions. It can employ any of the permissions defined by Android (listed in ) or declared by other applications. Or it can define its own. A new permission is declared with the  element. For example, an activity could be protected as follows:

. . .
. . .

Note that, in this example, the DEBIT_ACCT permission is not only declared with the  element, its use is also requested with the  element. Its use must be requested in order for other components of the application to launch the protected activity, even though the protection is imposed by the application itself. 

If, in the same example, the permission attribute was set to a permission declared elsewhere (such as android.permission.CALL_EMERGENCY_NUMBERS, it would not have been necessary to declare it again with a  element. However, it would still have been necessary to request its use with 

The  element declares a namespace for a group of permissions that will be defined in code. And  defines a label for a set of permissions (both those declared in the manifest with  elements and those declared elsewhere). It affects only how the permissions are grouped when presented to the user. The  element does not specify which permissions belong to the group; it just gives the group a name. A permission is placed in the group by assigning the group name to the element's  attribute.

Libraries

Every application is linked against the default Android library, which includes the basic packages for building applications (with common classes such as Activity, Service, Intent, View, Button, Application, ContentProvider, and so on).

However, some packages reside in their own libraries. If your application uses code from any of these packages, it must explicitly asked to be linked against them. The manifest must contain a separate element to name each of the libraries. (The library name can be found in the documentation for the package.)

转载地址:http://roiuo.baihongyu.com/

你可能感兴趣的文章
SDK目录结构
查看>>
ActiveMQ(25):优化与建议
查看>>
使用Intelij Idea经过的坑
查看>>
微信 token
查看>>
【原创】JAVA通过过滤器防止脚本注入
查看>>
马哥linux第8周作业
查看>>
gnu autotools
查看>>
在AIX上增加文件系统空间
查看>>
svchost cpu占用率过高电脑卡死
查看>>
【中小企业经典案例分析一】基础架构描述
查看>>
Android进程间通信(IPC)机制Binder简要介绍和学习计划
查看>>
在git@osc上托管自己的代码
查看>>
Training的第五天
查看>>
软件架构师的职责范围谈
查看>>
计算思维与创新创业 课程 获批
查看>>
yum install 时遇到 HTTP 404 page not found错误
查看>>
细说五层网站架构
查看>>
搭建ubuntu环境
查看>>
Xen命令全集
查看>>
水环境指标 中文对照
查看>>