ActivityCompat.requestPermissions不显示对话框

时间:2022-09-29 22:22:23

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

在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.

调用requestPermissions()后,将调用onRequestPermissionsResult而不显示确认对话框。

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

有谁知道问题是什么,或者如何显示这个对话框?

Thank you.

1 个解决方案

#1


0  

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.

要从头开始测试,请首先卸载您的应用,然后重试。这样,所有以前授予的权限都将被撤销。

#1


0  

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.

要从头开始测试,请首先卸载您的应用,然后重试。这样,所有以前授予的权限都将被撤销。