android bluetoothadapter.startLeScan, filter by UUID

只愿长相守 提交于 2019-12-10 18:05:06

问题


I want to scan BLE device with the startLeScan(UUID[] serviceUuids, LeScanCallback callback) method, now I have a UUID, it's a 16-bits value, for example, 00000000-0000-1000-8000-00805F9B34FB.

How can I use the UUID in startLeScan method, I write like this,

UUID[] uuid = new UUID[1]; uuid[0] = UUID.fromString("00000000-0000-1000-8000-00805F9B34FB");
mBluetoothAdapter.startLeScan(uuid, mLeScanCallback);

But finally I can scan nothing. How can I resolve this problem.


回答1:


I used the same method as you,and i added permissions in AndroidManifest.xml file like below:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

hope that will help you.



来源:https://stackoverflow.com/questions/30256110/android-bluetoothadapter-startlescan-filter-by-uuid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!