需要为 Android 10.0 上的低功耗蓝牙扫描启用定位 [英] Location needs to be enabled for Bluetooth Low Energy Scanning on Android 10.0

查看:26
本文介绍了需要为 Android 10.0 上的低功耗蓝牙扫描启用定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的 Pixel XL 升级到 Android 10.0 版后,蓝牙低功耗 (BLE) 扫描仅在我打开定位功能时才有效.

After upgrading my Pixel XL to Android version 10.0 Bluetooth Low Energy (BLE) scanning will only work if i have Location turned on.

直到现在这都不是问题,它可以在运行 Android 9.0、8.0 和 6.0.1 的多个设备上运行.

This has not been an issue until now and it's working on multiple devices running on Android 9.0, 8.0 and 6.0.1.

我的应用程序仅使用 BluetoothLeScanner 在前台进行扫描 startScan(List filters, ScanSettings settings, ScanCallback callback)

My app is only scanning in foreground using BluetoothLeScanner startScan(List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)

我的应用有 FINE_LOCATION、COARSE_LOCATION 和 BLUETOOTH 权限,我尝试添加 ACCESS_BACKGROUND_LOCATION 权限但没有成功.

My app has FINE_LOCATION, COARSE_LOCATION and BLUETOOTH permissions, I've tried adding ACCESS_BACKGROUND_LOCATION permission but had no luck.

Android 10.0 是否对应用扫描蓝牙设备有更严格的要求,我找不到任何关于此的信息,我希望我不必要求用户打开位置信息才能让我的应用正常工作.

Are there stricter requirements in Android 10.0 for apps to scan for Bluetooth devices, i can't find anything about this and am hoping i don't have to ask users to turn on Location for my app to work.

推荐答案

从 Android 10 开始,现在需要打开 ACCESS_FINE_LOCATION 才能执行蓝牙操作.这样做的原因是蓝牙可用于收集有关用户位置的信息(例如使用 BLE 信标),为此应声明相关应用权限.

As of Android 10, it is now required to have ACCESS_FINE_LOCATION turned on in order to perform Bluetooth operations. The reason for this is that Bluetooth can be used to gather information about the location of the user (e.g. using BLE beacons), and for that the relevant app permission should be declared.

对于 Android 9 及更低版本,ACCESS_COARSE_LOCATION 就足够了,这可能就是您的应用可以正常运行的原因.

For Android 9 and lower, ACCESS_COARSE_LOCATION is sufficient which is probably why your app was working without an issue.

可以在此处找到更多信息:-

More information can be found here:-

我希望这会有所帮助.

这篇关于需要为 Android 10.0 上的低功耗蓝牙扫描启用定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆