BluetoothKit框架只能扫描到已配对的设备
//设备扫描
//支持经典蓝牙和BLE设备混合扫描,可自定义扫描策略。每次扫描都要创建新的SearchRequest,不能复用。
SearchRequest request = new SearchRequest.Builder()
.searchBluetoothLeDevice(3000, 3) // 先扫BLE设备3次,每次3s
.searchBluetoothClassicDevice(5000) // 再扫经典蓝牙5s
.searchBluetoothLeDevice(2000) // 再扫BLE设备2s
.build();
mClient.search(request, new SearchResponse() {
@Override
public void onSearchStarted() {
Log.i("TAG","onSearchStarted");
}
@Override
public void onDeviceFounded(SearchResult device) {
Log.i("TAG","onDeviceFounded");
Beacon beacon = new Beacon(device.scanRecord);
Log.e("TAG",device.getAddress()+"--"+device.getName());
data.add(device.getName());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
BluetoothActivity.this, android.R.layout.simple_list_item_1, data);
ListView listView = findViewById(R.id.bleList);
listView.setAdapter(adapter);
}
2021-12-06 17:27:52.906 22195-22195/com.example.tippy E/TAG: 68:A8:E1:09:76:5D--SPEN (765D) ZK
2021-12-06 17:27:52.908 22195-22195/com.example.tippy E/TAG: DC:0C:5C:E2:BE:01--Breeze的 iPhone7 plus
2021-12-06 17:27:52.910 22195-22195/com.example.tippy E/TAG: 5C:C6:E9:6F:38:88--HECATE GM6 L
2021-12-06 17:27:52.912 22195-22195/com.example.tippy E/TAG: 04:FE:A1:A3:BC:AA--EDIFIER R101BT
延长扫描时间
已配对和未配对的都能扫描出来