我只想在开始发现蓝牙设备时发现外围设备,我的应用不得发现/显示其他设备。这怎么可能?
这就是我搜索设备的方式
IntentFilter filter = new IntentFilter("android.bluetooth.devicepicker.action.DEVICE_SELECTED");
registerReceiver(mBtPickReceiver,filter);
startActivity(new Intent("android.bluetooth.devicepicker.action.LAUNCH")
.putExtra("android.bluetooth.devicepicker.action.EXTRA_NEED_AUTH",false));
最佳答案
要根据您的要求减少(过滤)搜索设备的数量,请检查所需蓝牙设备的类类型。知道类型后,您可以根据类类型过滤搜索到的蓝牙设备。例如:
BluetoothDevice btd = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if(btd.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.bla_bla_bla)
{
//do whatever you want with the filtered device
}
关于java - 将过滤器添加到蓝牙发现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12245135/