android - Marshmallow app permission revoke notification? -
this question has answer here:
in android 6.0 (marshmallow), users can revoke specific app permissions, after granting inside app. know can check permissions contextcompat.checkselfpermission(). there way app notified when user revokes 1 of app's permissions, without repeated checking contextcompat.checkselfpermission()? maybe broadcast/intent or similar?
thanks in advance help.
if app needs dangerous permission, must check whether have permission every time perform operation requires permission. user free revoke permission, if app used permission yesterday, can't assume still has permission today.
to check if have permission, call contextcompat.checkselfpermission() method. example, snippet shows how check if activity has permission write calendar:
// assume thisactivity current activity int permissioncheck = contextcompat.checkselfpermission(thisactivity, manifest.permission.write_calendar); if app has permission, method returns packagemanager.permission_granted, , app can proceed operation. if app not have permission, method returns permission_denied, , app has explicitly ask user permission.
Comments
Post a Comment