【发布时间】:2015-09-21 16:23:23
【问题描述】:
我正在开发一个通过低功耗蓝牙连接到设备的 Android 应用。
我的问题是我无法找到一种方法来连接我之前连接的设备。在手机的蓝牙设置中,蓝牙设备显示为“已配对”,所以我想从应用程序连接到它以与它“交谈”。
有人知道怎么做吗?
提前致谢!
【问题讨论】:
标签: android bluetooth bluetooth-lowenergy android-bluetooth
我正在开发一个通过低功耗蓝牙连接到设备的 Android 应用。
我的问题是我无法找到一种方法来连接我之前连接的设备。在手机的蓝牙设置中,蓝牙设备显示为“已配对”,所以我想从应用程序连接到它以与它“交谈”。
有人知道怎么做吗?
提前致谢!
【问题讨论】:
标签: android bluetooth bluetooth-lowenergy android-bluetooth
您可以从 BluetoothAdapter 获取绑定设备列表:
Set<BluetoothDevice> devices = myBluetoothAdapter.getBondedDevices();
然后识别您感兴趣的设备并连接:
myBluetoothGatt = myBluetoothDevice.connectGatt(context, false, myGattCallback);
【讨论】: