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







【android】uses-permission和permission具体解释的更多相关文章

  1. Android权限管理之Permission权限机制及使用

    前言: 最近突然喜欢上一句诗:"宠辱不惊,看庭前花开花落:去留无意,望天空云卷云舒." 哈哈~,这个和今天的主题无关,最近只要不学习总觉得生活中少了点什么,所以想着围绕着最近面试过 ...

  2. Android自定义action与permission!!! (转)

    原文地址:http://blog.csdn.net/android_tutor/article/details/6310418#reply 大家好,今天给大家简单分享一下Android中自定义acti ...

  3. Android Touch事件传递机制具体解释 下

    尊重原创:http://blog.csdn.net/yuanzeyao/article/details/38025165 资源下载:http://download.csdn.net/detail/yu ...

  4. Failed to obtain lock on file /usr/local/nagios/var/ndo2db.lock: Permission denied : Permission denied

    Failed to obtain lock on file /usr/local/nagios/var/ndo2db.lock: Permission denied  : Permission den ...

  5. Android各种访问权限Permission详解

    原文:http://jingyan.baidu.com/article/afd8f4de4688af34e386e976.html 在Android的设计中,资源的访问或者网络连接,要得到这些服务都需 ...

  6. android:各种访问权限Permission

    在Android的设计中,资源的访问或者网络连接,要得到这些服务都需要声明其访问权限,否则将无法正常工作.在Android中这样的权限有很多种,这里将各类访问权限一一罗列出来,供大家使用时参考之用. ...

  7. Android开发-API指南-<permission>

    <permission> 英文原文:http://developer.android.com/guide/topics/manifest/permission-element.html 采 ...

  8. android: open failed: EACCES (Permission denied)

    1.  问题描述:在Android中,用程序访问Sdcard时,有时出现“java.io.IOException: open failed: EACCES (Permission denied)&qu ...

  9. Android java.io.FileNotFoundException:*** (Permission denied)

    自从离开上海来到杭州之后,陆续接触了Android,Python,C++,OpenCV,最为一个新人来说,一路上遇到了很多坑,幸运的是 这互联网的强大(大傻子我还是蛮喜欢的哈),一路填填补补总算走了下 ...

随机推荐

  1. 微信js sdk上传多张图片

    微信js sdk上传多张图片,微信上传多张图片 该案例已tp3.2商城为例 直接上代码: php代码: public function ind(){ $appid="111111111111 ...

  2. 5.29MyBatis Generator

    二.MyBatis Generator CRUD(创建,检索,更新,删除) 与表结构匹配的Java POJO BLOB (binary large object),二进制大对象,是一个可以存储二进制文 ...

  3. Vue初级

    来学习vue.js的宝宝们应该都了解了什么是vue并且是有兴趣去学的,我也是自己学习vue,欢迎大家一起讨论. 现在,我么先自己尝试用vue来写个hello world吧. 一.创建一个 .html  ...

  4. android 将手机号中间隐藏为星号(*)

    ){ StringBuilder sb =new StringBuilder(); ; i < pNumber.length(); i++) { char c = pNumber.charAt( ...

  5. 【VB】api实现窗口最小化

    Const WM_SYSCOMMAND = &H112 Const SC_MINIMIZE = &HF020& SendMessage hWnd, WM_SYSCOMMAND, ...

  6. JSP_内置对象_session

    session表示客户端与服务器的一次会话. Web中的session指的是用户在浏览某个网站时,从进入网站到浏览器关闭所经过的这段时间,也就是用户浏览这个网站所花费的时间. 从上述定义中可以看到,s ...

  7. Cache-Control 机制是为浏览器定制的?

    Cache-Control 机制是为浏览器定制的?

  8. Hadoop-2.2.0集群部署时live nodes数目不对的问题

    关于防火墙,hadoop本身配置都确定没任何问题,集群启动不报错,但打开50070页面,始终live nodes数目不对,于是我尝试/etc/hosts文件配置是否存在逻辑的错误: 127.0.0.1 ...

  9. BZOJ 5466: [Noip2018]保卫王国 动态DP

    Code: // luogu-judger-enable-o2 #include<bits/stdc++.h> #define ll long long #define lson (now ...

  10. 【转载】JavaWeb之DBUtils QueryRunner类对数据表的增、删、查(8种结果集处理方式)、改操作

    一.使用QueryRunner类,实现对数据表的 insert delete update package com.shuhuadream.queryrunner; import java.sql.C ...