ActivityCompat.requestPermissions does not 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 calling requestPermissions (), onRequestPermissionsResult is called without displaying a confirmation dialog.

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

Thanks.

+6
source share
1 answer

This is probably because you have already granted the required permission for your application.

To test from scratch, first uninstall the application and then try again. Therefore, all previously granted permissions will be revoked.

0
source

All Articles