简体   繁体   English

ACTION_LOCATION_SOURCE_SETTINGS 仅开启 GPS 但在 Android 中仍未授予权限 10

[英]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.

相关问题 ACTION_LOCATION_SOURCE_SETTINGS:无法解析或不是字段 - ACTION_LOCATION_SOURCE_SETTINGS : cannot be resolved or is not a field android.permission.WRITE_SETTINGS 是否仅授予系统应用程序? - Is android.permission.WRITE_SETTINGS only granted to system apps? 已授予 Android 权限但仍拒绝权限 - Android permission granted but still permission denied Android运行时权限已被授予但仍被拒绝 - Android runtime permission is GRANTED but still denied “写设置”权限未授予marshmallow android - “Write settings” permission not granted marshmallow android Android设置。ACTION_LOCATION_SOURCE_SETTINGS导致崩溃 - Android Settings.ACTION_LOCATION_SOURCE_SETTINGS resulting in crash 打开位置 (GPS) 的操作/意图是什么 - What is the Action/Intent to turn ON Location (GPS) 调试时授予位置权限,但在android系统上未授予 - Permission for location is granted while debugging however not granted on android system 如果GPS已打开,则Android设置API会打开WiFi,以提高位置准确性 - Android Settings API turn on WiFi to improve location accuracy if GPS is already turned on Android 6.0 = PERMISSION_NOT_GRANTED(具有CONTACTS和LOCATION权限的问题) - Android 6.0 = PERMISSION_NOT_GRANTED (Issue with CONTACTS and LOCATION permission)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM