简体   繁体   English

Android Java动态设置应用程序权限

[英]Android java set app permissions dynamically

Is it possible to set android app permission dynamically in java , usually it is set in AndroidManifest.xml . 是否可以在java动态设置android应用permission ,通常是在AndroidManifest.xml设置。 But what I want to do is giving my users a choice of what permissions they want my app to give. 但是我要做的是让用户选择他们想要我的应用程序permissions thanks in advance! 提前致谢!

No, it is not currently possible. 不可以,目前无法实现。 Up through Android Lollipop, permissions must be explicitly requested in the app's manifest and must be collectively all granted or denied (not installing the app) by the user at install time. 通过Android Lollipop,必须在应用程序的清单中显式请求权限,并且必须在安装时由用户共同授予或拒绝所有权限(不安装应用程序)。

Android M, however, is changing this. 但是,Android M正在对此进行更改。 As of Android M, permissions will be granted at runtime instead of at install time, allowing you to give users more control over which permissions they allow your app to use. 从Android M开始,权限将在运行时(而不是安装时)授予,从而使用户可以更好地控制他们允许您的应用使用的权限。

See the Android M runtime permissions documentation for more detail. 有关更多详细信息,请参见Android M运行时权限文档

At the moment it's not possible http://developer.android.com/guide/topics/security/permissions.html 目前无法http://developer.android.com/guide/topics/security/permissions.html

Android has no mechanism for granting permissions dynamically (at run-time) because it complicates the user experience to the detriment of security.

Things may change in new android M release 新的android M版本可能会改变

Nope. 不。 App's permissions are declared in AndroidManifest.xml, which is used to tell Android system what permissions are required. 应用的权限在AndroidManifest.xml中声明,该属性用于告诉Android系统需要哪些权限。 App installer will show all permissions to help user judge the app is good or bad. 应用安装程序将显示所有权限,以帮助用户判断应用的好坏。

Thing about that if an malicious app require nothing at install-time and require camera permission at run-time dynamically 如果恶意应用在安装时不需要任何东西,而在运行时动态要求获得摄像头许可,则该问题

It would be against Android policy . 这将违反Android政策。 The application has or not has the permissions for doing something . 该应用程序具有执行某项操作的权限。 It can be a security problem if you can think of it. 如果您能想到的话,这可能是一个安全问题。 It is possible no issue but in mid of app if not get then chances of getting crash in your app... 可能没有问题,但是在应用程序中途,如果没有,则可能会导致应用程序崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM