Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant permission Manifest.permission.MANAGE_DOCUMENTS android 6.0

I want to grant the permission Manifest.permission.MANAGE_DOCUMENTS, but when I run the app, the dialog of the permission should appear but it doesn't. Here's my code:

int hasCameraPermission = ContextCompat.checkSelfPermission(MemoryDetail.this, Manifest.permission.MANAGE_DOCUMENTS);
if (hasCameraPermission != PackageManager.PERMISSION_GRANTED) {
    if (!ActivityCompat.shouldShowRequestPermissionRationale(MemoryDetail.this, Manifest.permission.MANAGE_DOCUMENTS)) {
        showDialogMessage("Need use permission: MANAGE_DOCUMENTS", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    requestPermissions(new String[] {Manifest.permission.MANAGE_DOCUMENTS}, Database.PICK_PICTURE);
                }
            }
        });

    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        requestPermissions(new String[]{Manifest.permission.MANAGE_DOCUMENTS}, Database.PICK_PICTURE);
    }
    return;
}
like image 506
mytruong Avatar asked Jan 07 '23 13:01

mytruong


1 Answers

MANAGE_DOCUMENTS is a signature-level permission. Ordinary Android apps cannot hold it. Only apps that were signed by the same signing key that signed the firmware can hold it.

like image 101
CommonsWare Avatar answered Mar 25 '23 21:03

CommonsWare