Android 蓝牙扫描权限问题

上网找的demo中使用的是ACCESS_COARSE_LOCATION,看文档实际上应该使用ACCESS_FINE_LOCATION
虽然同属一个权限组 但是用ACCESS_COARSE_LOCATION会导致蓝牙扫描不出来
这俩区别也可以看文档:
精确度级别取决于您请求的具体权限:
ACCESS_COARSE_LOCATION 提供设备位置的估算值,将范围限定在大约 1.6 公里(1 英里)内。
ACCESS_FINE_LOCATION 提供尽可能准确的设备位置估算值,通常将范围限定在大约 50 米(160 英尺)内,有时精确到几米(10 英尺)范围以内。 这是某些连接任务(例如通过蓝牙低功耗 [BLE] 连接到附近的设备)所必需的权限。

To use Bluetooth features in your app, you must declare two permissions:

  • BLUETOOTH is necessary to perform any Bluetooth communication, such as requesting a connection, accepting a connection, and transferring data.
  • ACCESS_FINE_LOCATION is necessary because a Bluetooth scan can gather information about the location of the user. This information may come from the user's own devices, as well as Bluetooth beacons in use at locations such as shops and transit facilities.

Since ACCESS_FINE_LOCATION is a dangerous permission, you must request this permission at runtime along with declaring it in your manifest.

你可能感兴趣的:(Android 蓝牙扫描权限问题)