如何获取蓝牙设备的信息,可用其他蓝牙设备和连接通知?
答案 0 :(得分:5)
要获取蓝牙设备,您必须获取BluetoothAdapter的实例并调用startDiscovery()
方法。您还需要注册ACTION_FOUND
意图。它可以这样做:
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()
方法。