博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【android】uses-permission和permission具体解释
阅读量:4956 次
发布时间:2019-06-12

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

1.<uses-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.

假设一个应用须要訪问一个受permission保护的特性,那这个应用必须在manifest中以节点声明它所须要的权限。当这个应用安装在设备的时候,安装器会决定是否授予它所声明的权限。这有时候会询问用户。假设权限被授予了,这个应用才干使用受保护的特性。否则的话。訪问失败而且不会通知用户。

注意:不一定是调用其它应用程序才要声明。有时甚至调用自己应用的程序的组件都要声明!!

!(以下的样例会说到)

2.<permission>:

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. 

一个应用程序也能用permissions保护自己的组件。它能使用android系统定义的或者其它应用定义的又或者自身应用定义的permissions。假设要想定义一个新的permission,能够用 节点来定义。

例如以下:

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 asandroid.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 .

注意的是。在这个样例中。 DEBIT_ACCT这个权限不仅在<permission>中声明。而且也在<uses-permission>中声明。要想在这应用的其它组件启动这个受保护的activity时,在<uses-permission>中声明DEBIT_ACCT这个权限是必须的,即使这个保护是这个应用本身加上的。(这印证了上面第1点说的)。

注意,假设加入的permission是其它地方定义的,那就不是必需再<permission>声明一次。可是,仍然用<uses-permission>声明这个权限。

參考:

http://developer.android.com/guide/topics/manifest/manifest-intro.html#perms

http://berdy.iteye.com/blog/1782854

http://blog.csdn.net/lilu_leo/article/details/6940941

转载于:https://www.cnblogs.com/yfceshi/p/7089910.html

你可能感兴趣的文章
CI 日志类
查看>>
3.28上午
查看>>
Servlet学习-会话技术session
查看>>
thinkphp之cookie操作
查看>>
对 Linux 新手非常有用的 20 个命令
查看>>
QT设置标签字体大小和颜色
查看>>
codevs 1332 上白泽慧音
查看>>
XML之DOM解析文档 Day24
查看>>
org.hibernate.AnnotationException: No identifier specified for entity:
查看>>
转:php 5.5源码安装全过程
查看>>
结对编程总结by黄柏欣李斌
查看>>
序列号的设计,不重复的实现一机一码
查看>>
苹果充电器USB端的识别电阻的设置
查看>>
elasticsearch的模糊查询
查看>>
贪心、分治基础
查看>>
Eqs - poj 1840(hash)
查看>>
JavaScript把项目本地的图片或者图片的绝对路径转为base64字符串、blob对象在上传...
查看>>
关于Tag的详细介绍
查看>>
查看更多
查看>>
HDU 3488 Tour【多个环的并】
查看>>