ActivityCompat.requestPermissions 不显示 ACCESS_FINE_LOCATION 的对话框
ActivityCompat.requestPermissions does not show dialog for ACCESS_FINE_LOCATION
我的应用程序在从 web 视图触发地理定位权限请求时请求 ACCESS_FINE_LOCATION 权限,但它调用 onRequestPermissionsResult 甚至没有显示对话框,其响应为 PERMISSION_DENIED。我已经阅读了几乎所有关于这个主题的帖子,但其中 none 似乎解决了我的问题:(
在 WebChrome 客户端中:
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
int permissionCheck = ContextCompat.checkSelfPermission(onActivity, android.Manifest.permission.ACCESS_FINE_LOCATION);
if (permissionCheck == -1){
ActivityCompat.requestPermissions(onActivity, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, MainActivity.REQUEST_GEOLOCATION);
}else if (permissionCheck == 0){
callback.invoke(origin, true, false);
}
}
以下是从我的清单中请求的权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
tools:ignore="ScopedStorage"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.Manifest.permission.ACCESS_FINE_LOCATION" />
对于sdk版本,我有minSdkVersion 23,targetSdkVersion 29。
替换:
<uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.Manifest.permission.ACCESS_FINE_LOCATION" />
与:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
我的应用程序在从 web 视图触发地理定位权限请求时请求 ACCESS_FINE_LOCATION 权限,但它调用 onRequestPermissionsResult 甚至没有显示对话框,其响应为 PERMISSION_DENIED。我已经阅读了几乎所有关于这个主题的帖子,但其中 none 似乎解决了我的问题:(
在 WebChrome 客户端中:
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
int permissionCheck = ContextCompat.checkSelfPermission(onActivity, android.Manifest.permission.ACCESS_FINE_LOCATION);
if (permissionCheck == -1){
ActivityCompat.requestPermissions(onActivity, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, MainActivity.REQUEST_GEOLOCATION);
}else if (permissionCheck == 0){
callback.invoke(origin, true, false);
}
}
以下是从我的清单中请求的权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
tools:ignore="ScopedStorage"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.Manifest.permission.ACCESS_FINE_LOCATION" />
对于sdk版本,我有minSdkVersion 23,targetSdkVersion 29。
替换:
<uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.Manifest.permission.ACCESS_FINE_LOCATION" />
与:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />