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

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

!(以下的样例会说到)



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 inandroid.Manifest.permission)
or declared by other applications. Or it can define its own. A new permission is declared with the <permission> element.



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

例如以下:

<permission android:description="string resource"
            android:icon="drawable resource"
            android:label="string resource"
            android:name="string"
            android:permissionGroup="string"
            android:protectionLevel=["normal" | "dangerous" |
                                     "signature" | "signatureOrSystem"] />

For
example, an activity could be protected as follows:

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

Note that, in this example, the DEBIT_ACCT permission is not only declared with the <permission> element,
its use is also requested with the <uses-permission> 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<permission> element.
However, it would still have been necessary to request its use with <uses-permission>.

注意的是。在这个样例中。 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







最新文章

  1. 使用C#,轻松发邮件之QQ邮箱
  2. S1293和S2220KTV项目结束
  3. 演示一个导致ora-01555错误的场景
  4. 分布式架构高可用架构篇_04_Keepalived+Nginx实现高可用Web负载均衡
  5. 目前用到最全的datagrid(easyui)
  6. java易混淆概念之类变量、成员变量、局部变量
  7. vs 行数
  8. 看文章《EAI和SOA的比较》有感(1)
  9. Beego学习笔记——Logs
  10. CSS3秘笈复习:第七章
  11. php 生成 验证码的例子
  12. Redis缓存服务搭建及实现数据读写--转载
  13. Cordova各个插件使用介绍系列(五)—$cordovaGeolocation获取当前位置
  14. javasript校验字符串【正则和其他函数】
  15. CCF系列之门禁系统(201412-1)
  16. Pandas 把数据写入csv
  17. spring源码解析1--spring整体架构
  18. JavaScript——变量
  19. numpy二进制转换和范围缩放
  20. 《C++ Primer Plus》第9章 内存模型和名称空间 学习笔记

热门文章

  1. CSS--浏览器CSS Hack 收集
  2. PCB 无需解压,直接读取Zip压缩包指定文件 实现方法
  3. PCB MS SQL 小写转大写
  4. 0502 php简单了解
  5. CodeForces A. Meeting of Old Friends
  6. Spring boot -环境搭建 ,初步接触(1)
  7. php常见报错
  8. php数据库批量删除
  9. VHDL之std_logic_1164
  10. selenium有多个窗口时操作某个窗口的内容