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 in android.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 as android.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>声明这个权限。

uses-permission和permission详解相关推荐

  1. Python报错:PermissionError: [Errno 13] Permission denied 解决方案详解

    出现错误的原因: 1.文件找不到, 2.文件被占用, 3.文件无权限访问, 4.打开的不是文件,而是一个目录, 我就是这个问题,打开的是一个目录

  2. Python报错:PermissionError: [Errno 13] Permission denied解决方案详解

    报错信息 使用python做数据集的过程中,报如下错误: 错误原因 报错翻译过来是: 权限错误:[errno 13]权限被拒绝: 错误产生的原因是文件无法打开,可能产生的原因是文件找不到,或者被占用, ...

  3. cat命令详解_Linux | 账号管理及命令使用详解

    引言   在Linux系统中,我们常常会看到目录或文件的所属关系: [root@linux01 ~]# ll -d test.sh -rw-r----- 1 root root 144 11月 20 ...

  4. Linux—账号管理及命令使用详解

    关注微信公众号:CodingTechWork,一起学习进步. 引言   在Linux系统中,我们常常会看到目录或文件的所属关系: [root@linux01 ~]# ll -d test.sh -rw ...

  5. Permission 使用详解

    极力推荐文章:欢迎收藏Android 干货分享 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以下内容: 安全架构设计 应用签名 用户ID 和文件访问 使用权限 正常 ...

  6. Android permission权限详解

    权限是一种安全机制.Android权限主要用于限制应用程序内部某些具有限制性特性的功能使用以及应用程序之间的组件访问.在Android开发中,基本上都会遇到联网的需求,我们知道都需要加上联网所需要的权 ...

  7. 以SIGSEGV为例详解信号处理(与栈回溯)

    以SIGSEGV为例详解信号处理(与栈回溯) 信号是内核提供的向用户态进程发送信息的机制, 常见的有使用SIGUSR1唤醒用户进程执行子程序或发生段错误时使用SIGSEGV保存用户错误现场. 本文以S ...

  8. AndroidManifest.xml配置文件详解

    AndroidManifest.xml配置文件详解 . AndroidManifest.xml配置文件对于Android应用开发来说是非常重要的基础知识,本文旨在总结该配置文件中重点的用法,以便日后查 ...

  9. Linux操作系统上lsof命令详解

    Linux操作系统上lsof命令详解 2011-10-08 18:31:31 http://xjsunjie.blog.51cto.com/999372/682865 标签:Linux lsof命令 ...

  10. Kooboo CMS - Html.FrontHtml.Position 详解

    DataContract 数据契约 http://www.cnblogs.com/Gavinzhao/archive/2010/06/01/1748736.html https://msdn.micr ...

最新文章

  1. python二级考试试题4答案_第4卷讲解Python语言计算机等级考试二级操作题
  2. bs4抓起大众点评的用户评论
  3. s:selected的用法
  4. SpringBoot整合Redis要注意的那些
  5. hibernate语句_如何优化Hibernate EllementCollection语句
  6. Java基础面试题与答案
  7. c语言找出递增子数组的长度,编程之美2.16 数组中最长递增子序列的长度
  8. 选择所有选项的多选复选框列表或复选框下拉列表
  9. mysql 表中中文不显示
  10. (日常搬砖)之environment.yml的使用
  11. 【dos命令--教程】批量修改文件后缀
  12. 如何在vue3.0项目中集成Element-plus
  13. 首席CEO乔布斯他是如何拉住了苹果快破产的边缘?他的运营方法是什么呢?
  14. 机器学习之理解支持向量机SVM
  15. 第三次小班讨论课——海明检验码、用晶体管而不是逻辑门实现异或门
  16. OpenCV 保存视频
  17. 一个武侠游戏的成就界面需要针对每一个成就阶段配一句话,阶段分别是:默默无闻、初涉江湖、小有所成、一代宗师。想一想你会怎么写这个文案
  18. 永磁同步电机PMSM,异步电机仿真矢量控制
  19. 达梦8 DCA认证笔记
  20. 集成公告|Exiled Racers即将带来部署在Moonbeam的3D NFT项目

热门文章

  1. 创业故事:加班何来制度?
  2. word中添加参考文献方法
  3. 以太坊RPC调用智能合约
  4. 前端设置cookie之vue-cookies
  5. 【观察】突破内存与存储瓶颈,英特尔傲腾从蓄势到爆发
  6. 机器学习与分布式机器学习_我如何学习机器学习
  7. 汽车电子软件开发需知
  8. 英语中表语从句的概念及其用法,例句(不断更新)
  9. vue 为全局变量赋值_vue定义全局变量和全局方法的方法示例
  10. DMI 获取硬件信息 CPU RAM 等