mik*_*ugo 13 android bluetooth android-6.0-marshmallow
我有一个使用蓝牙和连接设备的应用程序,无法使用BluetoothAdapter.getDefaultAdapter()找到任何设备.startDiscovery(); 它在发现之前工作得很好.尝试过其他应用程序,它也不适用于其他应用程序.但我尝试配对的设备(Arduino bt-module)可以在Android设置中找到.知道我能尝试什么吗?我实现了http://developer.android.com/guide/topics/connectivity/bluetooth.html上描述的所有内容,它在更新之前有效.
Meg*_*gha 31
蓝牙适配器已在Android 6.0中进行了更改
您需要设置权限ACCESS_FINE_LOCATION或ACCESS_COARSE_LOCATION权限,并需要使用BluetoothLeScanner.startScan()方法来启动扫描.
以下是更改日志的说明:
为了向用户提供更好的数据保护,在Android 6.0中,Android删除了使用Wi-Fi和蓝牙API对应用程序的设备本地硬件标识符的编程访问.WifiInfo.getMacAddress()和BluetoothAdapter.getAddress()方法现在返回一个常量值02:00:00:00:00:00.
要通过蓝牙和Wi-Fi扫描访问附近外部设备的硬件标识符,您的应用现在必须具有ACCESS_FINE_LOCATION或ACCESS_COARSE_LOCATION权限:
WifiManager.getScanResults()
BluetoothDevice.ACTION_FOUND
BluetoothLeScanner.startScan()
Run Code Online (Sandbox Code Playgroud)
注意:当运行Android 6.0(API级别23)的设备启动后台Wi-Fi或蓝牙扫描时,外部设备可以看到该操作来自随机MAC地址.
您可以从以下链接获取更多详细信息:http: //developer.android.com/about/versions/marshmallow/android-6.0-changes.html
| 归档时间: |
|
| 查看次数: |
21482 次 |
| 最近记录: |