簡體   English   中英

權限對話框未顯示android棉花糖

[英]Permission dialog is not being shown android marshmallow

我正在使用nexus 6 android 6.0,僅針對WRITE_EXTERNAL_STORAGE權限對話框未顯示其他危險權限。

final private int REQUEST_CODE_ASK_PERMISSIONS = 123;

@TargetApi(Build.VERSION_CODES.M)
private void insertDummyContactWrapper() {
    int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);

    // Here, thisActivity is the current activity
    if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

            // Show an expanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

        } else {

            // No explanation needed, we can request the permission.

            ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    110);

            // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    }
}

建立:

defaultConfig {
        applicationId "com.example.application"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

表現:

uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"

僅針對WRITE_EXTERNAL_STORAGE權限對話框未顯示其他危險權限

您的其他dangerous許可是READ_EXTERNAL_STORAGE 在我們請求權限並檢查權限的同時,在Android 6.0 UI中,用戶會授予(或拒絕)權限 READ_EXTERNAL_STORAGEWRITE_EXTERNAL_STORAGE在同一組中。

因此,如果用戶先前已授予您對READ_EXTERNAL_STORAGE的請求,則在您調用checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);時間點您已經擁有WRITE_EXTERNAL_STORAGE checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM