【问题标题】:How to retrieve Bluetooth Address through Name from Paired/bonded device list?如何通过名称从配对/绑定设备列表中检索蓝牙地址?
【发布时间】:2012-01-25 18:08:58
【问题描述】:

当我发现设备时,我实际上是这样做的:

IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
            this.registerReceiver(mDiscovery, filter);

在我的广播接收器中:

String action = intent.getAction();

if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

                    if (device.getBondState() != BluetoothDevice.BOND_BONDED) {

然后我可以执行 device.getName()device.getAddress()

我的问题是,我只知道如何通过intent 进行发现。因此,据我所知,android 设备都有已配对设备的列表,它们的名称作为各自的地址。

给定名称,我如何直接(无需发现,因此无需广播接收器)获取地址?

【问题讨论】:

    标签: java android bluetooth


    【解决方案1】:

    在您创建了 BluetoothAdapter 的对象(比如 mBluetoothAdatper)后,您可以使用 mBluetoothAdapter.getBondedDevices() 获得所有绑定(配对)设备的列表。 有关此link 的更多信息。

    【讨论】:

    • 这样你就可以在远程设备中使用 device.getName() 和 device.getAddress() 了。
    猜你喜欢
    • 2015-12-26
    • 1970-01-01
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    • 2016-11-28
    • 2012-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多