问题
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