[英]ACTION_LOCATION_SOURCE_SETTINGS only turn on GPS but permission is still not granted in Android 10
My app needs location, it works well in Android 9. But in Android 10, the ACTION_LOCATION_SOURCE_SETTINGS
doesn't grant the permission, only turn on the GPS.我的应用程序需要位置,它在 Android 9 中运行良好。但在 Android 10 中, ACTION_LOCATION_SOURCE_SETTINGS
不授予权限,只打开 Z8C578DE372785ADA208D763EA8。
@RequiresApi(api = Build.VERSION_CODES.M)
private void goToSettings() {
Intent myAppSettings = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(myAppSettings);
}
In manifest:在清单中:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
If I tried to use startActivityForResult
, no matter what action the user does, it always returns RESULT_CANCELED
如果我尝试使用startActivityForResult
,无论用户执行什么操作,它总是返回RESULT_CANCELED
[https://developer.android.com/about/versions/10/privacy/changes] [https://developer.android.com/about/versions/10/privacy/changes]
Android 10 introduces the ACCESS_BACKGROUND_LOCATION permission. Android 10 引入了 ACCESS_BACKGROUND_LOCATION 权限。
Unlike the ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions, the ACCESS_BACKGROUND_LOCATION permission only affects an app's access to location when it runs in the background.与 ACCESS_FINE_LOCATION 和 ACCESS_COARSE_LOCATION 权限不同,ACCESS_BACKGROUND_LOCATION 权限仅影响应用在后台运行时对位置的访问。 An app is considered to be accessing location in the background unless one of the following conditions is satisfied:除非满足以下条件之一,否则应用程序被视为在后台访问位置:
An activity belonging to the app is visible.属于该应用程序的活动是可见的。 The app is running a foreground service that has declared a foreground service type of location.该应用程序正在运行已声明前台服务类型位置的前台服务。
Perhaps you need to request the ACCESS_BACKGROUND_LOCATION permission.也许您需要请求 ACCESS_BACKGROUND_LOCATION 权限。
Also, I found this in the documentation另外,我在文档中找到了这个
ACTION_SECURITY_SETTINGS ACTION_SECURITY_SETTINGS
Activity Action: Show settings to allow configuration of security and location privacy.活动操作:显示设置以允许配置安全性和位置隐私。
Which might be the activity you need.这可能是您需要的活动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.