Android M permission issue with Dialog "Don't ask again"

It's a easier way to grant permission by Scoped Directory Access,but Dialog will show a checkbox named "Don't ask again". If the user selects Don't ask again and denies the request, all future requests for the given directory from your app will be automatically denied, and no request UI will be presented to the user. if user regret or hit that checkbox by mistake,how can app remedy? app can't get permission dialog.

How can we handle this?


我们应该使用shouldShowRequestPermissionRationale.Please通过这个:

private void insertDummyContactWrapper() {
        int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.WRITE_CONTACTS);
        if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) {
                if (!shouldShowRequestPermissionRationale(Manifest.permission.WRITE_CONTACTS)) {
                    showMessageOKCancel("You need to allow access to Contacts",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    requestPermissions(new String[] {Manifest.permission.WRITE_CONTACTS},
                                            REQUEST_CODE_ASK_PERMISSIONS);
                                }
                            });
                    return;
                }
            requestPermissions(new String[] {Manifest.permission.WRITE_CONTACTS},
                    REQUEST_CODE_ASK_PERMISSIONS);
            return;
        }
        insertDummyContact();
    }

is any way to change that flag ?

A developer cannot change that flag. Otherwise, there would be no point in having the checkbox, as developers would just ignore it by changing the flag.

However, your question points out a fairly substantial flaw in the scoped directory access: the user has limited ability to change that flag. There does not appear to be a place in Settings to change this state specifically, the way the user can manually grant a rejected runtime permission.

On a Nexus 5X running the 7.1 preview, "Clear Data" will reset this flag, though that has broader effects. On a Google Pixel running 7.1, and on a Nexus 5X running Android 7.0, nothing will reset this flag, even a full uninstall of the app.

I have filed a bug report about this. I am skeptical that the situation will be improved much in the short term — at best, they might fix it so "Clear Data" works reliably.


I think what you need to do is use the method shouldShowRequestPermissionRationale(String) it would return false if user has denied the permission and checked "Don't ask again".

What you should do is show an alert explaining the user why you need the permission or implement a fallback, like disable some feature.

Hope to be helpful.

链接地址: http://www.djcxy.com/p/93994.html

上一篇: 用ggplot2绘制3D棱镜并绘制

下一篇: 对话框的Android M权限问题“不要再询问”