[英]How to programmatically connect to a Bluetooth device after it's already paired (bonded) in Android
[英]How to retrieve Bluetooth Address through Name from Paired/bonded device list?
我在发现设备时实际上是这样做的:
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() 。
我的问题是,我只知道如何与意图的发现做到这一点。 因此,据我所知,Android设备的列表中包含成对设备,其名称分别作为地址。
给定名称,我如何直接(没有发现,就没有广播接收器)获得地址?
创建BluetoothAdapter对象(例如mBluetoothAdatper)后,您可以使用mBluetoothAdapter.getBondedDevices()获得包含所有绑定(配对)设备的列表。 有关此链接的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.