How to change denied/granted permission in Android M?

前端 未结 4 1672
清酒与你
清酒与你 2021-01-22 02:12

How can I give the user a chance to change his permissions in the App, which he has already set to granted/denied?

Let\'s say a user denied a permission. Later he want\

4条回答
  •  天命终不由人
    2021-01-22 02:41

    You show user a dialog asking to go to application settings and change the permission there, you have to motivate him somehow, tell why you need the permission. And you put an "Open settings" buton which triggers following function:

    private void startInstalledAppDetailsActivity() {
        final Intent i = new Intent();
        i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        i.addCategory(Intent.CATEGORY_DEFAULT);
        i.setData(Uri.parse("package:" + getPackageName()));
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        startActivity(i);
    }
    

提交回复
热议问题