创建你自己的权限 [英] Creating your own permissions

查看:126
本文介绍了创建你自己的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建一个使用您自己的权限 <使用-许可> 标记

Is it possible to create your own permissions using the <uses-permission> tag?

像这样

<uses-permission android:name="com.android.myapp.INSTALL_LICENSE"></uses-permission>

其中, com.android.myapp <​​/ code>是我包的名称, INSTALL_LICENSE 被许可使用者必须接受

Where com.android.myapp is the name of my package and INSTALL_LICENSE is the permission that users must accept

另外,我想budle一大堆现有的权限进入这个权限,以便客户端只需要声明一个许可,他们会在互联网,PHONE_STATE等权限。

In addition I would like to budle a whole lot of existing permissions into this one permission so client would only need to declare a single permission and they would get the INTERNET, PHONE_STATE and other permissions.

推荐答案

另外,我想budle一大堆现有的权限进入这个权限。

"In addition I would like to budle a whole lot of existing permissions into this one permission".

嗯,没有。这将是刻意引入安全漏洞,允许其他应用程序绕过的实际权限。我希望这将导致应用程序的市场被拉扯,一旦发现。

Um, no. That would be deliberately introducing a security hole, allowing other applications to bypass the actual permissions. I hope this would result in the app being pulled from Market, if it is found.

如果一个应用程序越来越接入INTERNET,PHONE_STATE,或者其他任何他们需要声明他们正在使用它直接与功能相关联的实际权限。

If an application is getting access to INTERNET, PHONE_STATE, or whatever else, they need to declare the real permission they are using which is directly associated with that functionality.

什么的的好是有自己的权限来限制应用程序访问你的功能,和你自己内部的.apk您使用其他的权限实现该功能......但这样做的的直接暴露,为应用程序。

What is okay is to have your own permission to restrict app access to your functionality, and inside of your own .apk you implement that functionality using other permissions... but do not directly expose that to the app.

在换句话说,这是正常的:声明许可DO_SOMETHING,它允许应用程序的说发送广播你将有你做一些事情,并返回一个真或假的结果,表示是否成功。

In other words, this is okay: Declare a permission for DO_SOMETHING, that allows an application to say send a broadcast do you that will have you do something and return a "true" or "false" result indicating whether it succeeded.

这是不行的:声明许可DO_SOMETHING,这暴露了一个API,该API允许应用程序获取手机状态,或发送他们提供关闭该设备的一些数据,或获取GPS信息

This is not okay: Declare a permission for DO_SOMETHING, which exposes an API that allows an application to retrieve the phone state, or send some data they provide off the device, or retrieve GPS information.

要声明一个允许在你的应用程序,你可以使用标签作为文档描述。

To declare a permission in your app, you use the tag as described in the docs.

但是你真正需要注意的:目前,如果一个应用程序被安装的的您的应用程序,并请求您的许可,它会的没有的拥有这个权限。 (由于权限是不知道它的安装时间。)才能被授予权限,它需要安装在您的应用程序后,重新安装或更新。

However something you really need to be aware of: currently if an app is installed before your app and requests your permission, it will not be granted that permission. (Because the permission was not known at the time it was installed.) For it to be granted the permission, it needs to be re-installed or updated after your app is installed.

这篇关于创建你自己的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆