如何获取蓝牙设备的信息、可用的其他蓝牙设备和连接通知?
最佳答案
要获得蓝牙设备,您必须获得 BluetoothAdapter 的实例并调用 startDiscovery()
方法。您还需要注册 ACTION_FOUND
Intent 。可以这样做:
private BroadcastReceiver mBlueToothInfoDiscoveryListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action))
{
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
}
}
要获取有关找到的设备的信息,您可以使用 getAddress()
方法。
关于android - 蓝牙连接通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5547774/