Skip to content

PermissionUtils定位部分ROM提示找不到android.permission.ACCESS_BACKGROUND_LOCATION #1408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yixiaolunhui opened this issue Dec 28, 2020 · 2 comments
Assignees
Labels

Comments

@yixiaolunhui
Copy link

yixiaolunhui commented Dec 28, 2020

  • AndroidUtilCode 的版本:1.30.5
  • 出现 Bug 的设备型号:谷歌 NEXUS 6P 、OPPO A57
  • 设备的 Android 版本:Android 6.0.1,level 23;Android 6.0,level 23

相关代码

 PermissionUtils.permission(PermissionConstants.LOCATION).request();

表单AndroidManifast.xml

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

异常堆栈

java.lang.RuntimeException:Failure delivering result ResultInfo{who=@android:requestPermissions:, request=1, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.foryou.truck/com.blankj.utilcode.util.UtilsTransActivity}: java.lang.IllegalArgumentException: Unknown permission: android.permission.ACCESS_BACKGROUND_LOCATION
--
2 android.app.ActivityThread.deliverResults(ActivityThread.java:3699)
3 ......
4 Caused by:
5 java.lang.IllegalArgumentException:Unknown permission: android.permission.ACCESS_BACKGROUND_LOCATION
6 android.os.Parcel.readException(Parcel.java:1624)
7 android.os.Parcel.readException(Parcel.java:1573)
8 android.content.pm.IPackageManager$Stub$Proxy.shouldShowRequestPermissionRationale(IPackageManager.java:2751)
9 android.app.ApplicationPackageManager.shouldShowRequestPermissionRationale(ApplicationPackageManager.java:522)
10 android.app.Activity.shouldShowRequestPermissionRationale(Activity.java:3874)
11 com.blankj.utilcode.util.PermissionUtils.getPermissionsStatus(PermissionUtils.java:380)
12 com.blankj.utilcode.util.PermissionUtils.onRequestPermissionsResult(PermissionUtils.java:416)
13 com.blankj.utilcode.util.PermissionUtils.access$1100(PermissionUtils.java:40)
14 com.blankj.utilcode.util.PermissionUtils$PermissionActivityImpl.onRequestPermissionsResult(PermissionUtils.java:511)
15 com.blankj.utilcode.util.UtilsTransActivity.onRequestPermissionsResult(UtilsTransActivity.java:139)
@lolucosmin
Copy link

Please review doc:
https://developer.android.com/training/location/permissions#background

Caution: If your app targets Android 11 (API level 30) or higher, the system enforces this best practice. If you request a foreground location permission and the background location permission at the same time, the system ignores the request and doesn't grant your app either permission.

You should create a seprate group for ACCESS_BACKGROUND_LOCATION.

Your current group:
private static final String[] GROUP_LOCATION = {
permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION, permission.ACCESS_BACKGROUND_LOCATION
};

@LeeeeeYao
Copy link

确实这个定位权限有问题,当你选择仅在使用次应用时允许时 回调的方法走的是rationale(),并没有走成功授权的回调

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants