Integrate new permission in android marshmallow

我的梦境 提交于 2019-12-25 03:38:15

问题


As we all know some changes have been made in api level 23(Android Marshmallow) in which we have to request for some permissions at run time that is on dangerous level like camera,read/write external storage etc. Is there any way to get Granular permissions from AndroidManifest file?


回答1:


Android Marshmallow introduces an entirely new spin on application permissions,Users now have the ability to revoke runtime permissions whenever they desire. This means that you can’t assume the app has access to the permission, even if it had been granted previously. You can refer this lib or this guide.I Hope this will help you out.




回答2:


1) You can get all the permissions given in your app using android api functions.

2) Then you can make a constant HashMap of dangerous permissions (which you are calling granular i guess).

3) When you will get all the permissions of your app just compare each permission individually either is it present in Dangerous Permissions HashMap or not.

Happy Coding :)




回答3:


Requesting permission is quite monotonous. One have to check permission each and every time whenever you use. For simplicity you can use PermissionAcceptor-master library.

Almost all permission is included in this library.

You have to add few lines of code using PermissionAcceptor-master library like

new PermissionRequest(MainActivity.this,
        Permission.PERMISSION_CAMERA,
        PermissionCode.CODE_PERMISSION_CAMERA,
        R.string.permission_camera_rationale,
        R.string.permission_camera_denied,
        R.string.permission_enable_message, this)
        .checkPermission();

For more information, visit PermissionAcceptor-master.



来源:https://stackoverflow.com/questions/33731886/integrate-new-permission-in-android-marshmallow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!