问题
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