[英]How to retrieve Bluetooth Address through Name from Paired/bonded device list?
I actually do this when I'm discovering devices: 我在发现设备时实际上是这样做的:
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mDiscovery, filter);
And in my in my Broadcastreceiver: 在我的广播接收器中:
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
And then I can do device.getName() and device.getAddress() . 然后我可以执行device.getName()和device.getAddress() 。
My problem is, I only know how to do this with an intent for the discovery. 我的问题是,我只知道如何与意图的发现做到这一点。 So, android devices as fair as I know have list with paired devices with their names as respective addresses.
因此,据我所知,Android设备的列表中包含成对设备,其名称分别作为地址。
Given the name, how can I directly (without discovery and so without a broadcast receiver) get the address? 给定名称,我如何直接(没有发现,就没有广播接收器)获得地址?
After you created an object of your BluetoothAdapter ( let's say mBluetoothAdatper) you can get a list with all of the bonded(paired) devices with mBluetoothAdapter.getBondedDevices(). 创建BluetoothAdapter对象(例如mBluetoothAdatper)后,您可以使用mBluetoothAdapter.getBondedDevices()获得包含所有绑定(配对)设备的列表。 More information on this link .
有关此链接的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.