uses-permission和permission详解
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>声明这个权限。
参考:
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
uses-permission和permission详解的更多相关文章
- Linux—账号管理及命令使用详解
关注微信公众号:CodingTechWork,一起学习进步. 引言 在Linux系统中,我们常常会看到目录或文件的所属关系: [root@linux01 ~]# ll -d test.sh -rw ...
- kafka启动时出现FATAL Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer) java.io.IOException: Permission denied错误解决办法(图文详解)
首先,说明,我kafk的server.properties是 kafka的server.properties配置文件参考示范(图文详解)(多种方式) 问题详情 然后,我启动时,出现如下 [hadoop ...
- Shiro基础知识03----shiro授权(编程式授权),Permission详解,授权流程(zz)
授权,也叫访问控制,即在应用中控制谁能访问哪些资源(如访问页面/编辑数据/页面操作等). 在权限认证中,最核心的是:主体/用户(Subject).权限(Permission).角色(Role).资源 ...
- Permission 使用详解
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以 ...
- Android Notification 详解(一)——基本操作
Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰 ...
- Android Notification 详解——基本操作
Android Notification 详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notificatio ...
- Android PopupWindow Dialog 关于 is your activity running 崩溃详解
Android PopupWindow Dialog 关于 is your activity running 崩溃详解 [TOC] 起因 对于 PopupWindow Dialog 需要 Activi ...
- Android 网络框架之Retrofit2使用详解及从源码中解析原理
就目前来说Retrofit2使用的已相当的广泛,那么我们先来了解下两个问题: 1 . 什么是Retrofit? Retrofit是针对于Android/Java的.基于okHttp的.一种轻量级且安全 ...
- Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
转载:http://freeloda.blog.51cto.com/2033581/1288553 大纲 一.前言 二.环境准备 三.安装与配置Nginx 四.Nginx之反向代理 五.Nginx之负 ...
- APP漏洞扫描器之本地拒绝服务检测详解
APP漏洞扫描器之本地拒绝服务检测详解 阿里聚安全的Android应用漏洞扫描器有一个检测项是本地拒绝服务漏洞的检测,采用的是静态分析加动态模糊测试的方法来检测,检测结果准确全面.本文将讲一下应用漏洞 ...
随机推荐
- ctrl+c,ctrl+d,ctrl+z在linux程序中意义和区别
原文: http://blog.csdn.net/sxhlovehmm/article/details/41318111 [侵删] ctrl+c和ctrl+z都是中断命令,但是他们的作用却不一样. ...
- linux的at定时任务的使用
linux的at定时任务的使用 使用at只能执行一次性任务:使用at命令需要开启atd进程. 以下情况需要安装at命令: 情况1.查看是否开启atd进程:ps -ef | grep atd.[test ...
- Redis数据结构之跳跃表
跳跃表是一种有序数据结构,它通过在每个节点中维持多个指向其他节点的指针,从而达到快速访问节点的目的. 一.跳跃表结构定义1. 跳跃表节点结构定义: 2. 跳跃表结构定义: 示例: 二.跳跃表节点中各种 ...
- (46)C#注册表及读写
启动注册表:regedit 结构: 注册表一共有7个配置单元用regedit只能看到5个 HKEY_CLASSES_ROOT 包含系统上文件类型的细节(.txt,.doc)等.以及使用那些应用程序可以 ...
- Linux命令之ss
1.ss -s 显示socket的统计信息 2.ss -a显示socket的详细信息 (ta:tcp,ua:udp) 3.ss -l显示本机监听的端口 4.ss -pl 显示本机监听的端口和程序 ht ...
- Codeforces 616 E Sum of Remainders
Discription Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the resu ...
- spark学习常用的操作
首先,使用 ScalaIDE 或 IDEA 创建 Scala 的 Maven 工程.需要用到 spark-core,spark-sql,spark-streaming 的 jar 包,pom 文件如下 ...
- ASP.NETCore使用AutoFac依赖注入
原文:ASP.NETCore使用AutoFac依赖注入 实现代码 1.新建接口类:IRepository.cs,规范各个操作类的都有那些方法,方便管理. using System; using Sys ...
- kafka的安装和使用;kafka常用操作命令
kafka:基于发布/订阅的分布式消息系统.数据管道:最初用来记录活动数据--包括页面访问量(Page View).被查看内容方面的信息以及搜索情况等内容和运营数据--服务器的性能数据(CPU.IO使 ...
- BUPT复试专题—统计节点个数(2013)
题目描述 给出一棵有向树,一共有n个节点,如果一个节点的度(入度+出度)不小于它所有儿子以及它父亲的度(如果存在父亲或儿子),那么我们称这个节点为p节点,现在你的任务是统计p节点的个数. 如样例,第一 ...