如何在Android开发中从蓝牙设置中检索蓝牙设备?
我正在设计一个应用程序,我希望通过点击按钮打开蓝牙设置。现在,当我进行设置时,我将配对并连接到附近的任何蓝牙设备。当我按下后退按钮并返回应用程序时,我希望能够在我的应用程序中将连接的设备检索为Bluetooth设备,以便我可以从我的应用程序中进一步操作它 现在我知道可以使用BluetoothAdapter、BluetoothSocket和BluetoothDevice从应用程序本身进行搜索、配对和连接,但我想知道是否有任何方法可以使用Bluetooth设置进行配对和连接,然后在我的应用程序中获取连接的设备如何在Android开发中从蓝牙设置中检索蓝牙设备?,android,bluetooth,android-bluetooth,Android,Bluetooth,Android Bluetooth,我正在设计一个应用程序,我希望通过点击按钮打开蓝牙设置。现在,当我进行设置时,我将配对并连接到附近的任何蓝牙设备。当我按下后退按钮并返回应用程序时,我希望能够在我的应用程序中将连接的设备检索为Bluetooth设备,以便我可以从我的应用程序中进一步操作它 现在我知道可以使用BluetoothAdapter、BluetoothSocket和BluetoothDevice从应用程序本身进行搜索、配对和连接,但我想知道是否有任何方法可以使用Bluetooth设置进行配对和连接,然后在我的应用程序中获取
谢谢你抽出时间 您可能需要查询绑定的设备。但您需要知道UUID或设备名称,以便获得正确的配对设备
Set<BluetoothDevice> devices = adapter.getBondedDevices();
if (devices != null) {
for (BluetoothDevice device : devices) {
if (deviceName.equals(device.getName())) {
result = device;
break;
}
}
}
Set devices=adapter.getBondedDevices();
如果(设备!=null){
用于(蓝牙设备:设备){
if(deviceName.equals(device.getName())){
结果=设备;
打破
}
}
}
一旦您拥有了设备,就可以envokeconnect