简体   繁体   中英

ActivityCompat.requestPermissions doesn't show dialog

In AndroidManifest.xml:

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="23" />
<uses-permission-sdk-m android:name="android.permission.ACCESS_FINE_LOCATION"/>

And in PreActivity.java

if (PermissionChecker.checkSelfPermission(preActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
    if (ActivityCompat.shouldShowRequestPermissionRationale(preActivity, Manifest.permission.ACCESS_FINE_LOCATION)){
        setDisplay();

    } else {
        // show dialog here
        ActivityCompat.requestPermissions(preActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_CODE);

    }
} else {
    ~~~~~
}

After requestPermissions() is called, onRequestPermissionsResult is called without showing confirmation dialog box.

Does anyone know what the problem is, or how to show this dialog?

Thank you.

This is probably happening because you have already granted the required permission to your app.

To test from scratch first uninstall your app and then try again. This way all of the previously granted permissions will be revoked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM