Android: 如果找到设备,有没有办法提前完成蓝牙广播接收器?
Android: Is there a way to finish a Bluetooth broadcast receiver early if a device is found?
我有一个 Android
应用程序需要连接到具有特定 name/MAC 的 Bluetooth
设备。有什么方法可以完成 BroadcastReceiver
以便一旦设备注册后它就会发送移动信号
从:
BluetoothDevice.ACTION_FOUND.equals(action)
到:
BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)
这样我就不必等到我的应用程序自然完成搜索了吗?
解决方案是放置此 if 语句:
if (device.getName().equals("SOME NAME")) {
mBluetoothAdapter.cancelDiscovery();
}
里面if (BluetoothDevice.ACTION_FOUND.equals(action))
我有一个 Android
应用程序需要连接到具有特定 name/MAC 的 Bluetooth
设备。有什么方法可以完成 BroadcastReceiver
以便一旦设备注册后它就会发送移动信号
从:
BluetoothDevice.ACTION_FOUND.equals(action)
到:
BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)
这样我就不必等到我的应用程序自然完成搜索了吗?
解决方案是放置此 if 语句:
if (device.getName().equals("SOME NAME")) {
mBluetoothAdapter.cancelDiscovery();
}
里面if (BluetoothDevice.ACTION_FOUND.equals(action))