蓝牙连接通知

Aja*_*ngh 3 android bluetooth

如何获取蓝牙设备的信息,可用的其他蓝牙设备和连接通知?

Gro*_*ook 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);
    }
 }
Run Code Online (Sandbox Code Playgroud)

要获取有关找到的设备的信息,您可以使用getAddress()方法.