我试图在一个范围内找到所有可用的蓝牙设备.但我只得到一个设备,我在运行方法的线程中使用它.我已经检查了很多关于此问题的链接,但无法解决此问题.这是我的代码
public void run() { if(service != null) { IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); service.registerReceiver(this.bReceiver, filter); bluetooth.startDiscovery(); } } class BluetoothReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { SetpairedDevices = bluetooth.getBondedDevices(); String action = intent.getAction(); if (pairedDevices.size() > 0) { for (BluetoothDevice device : pairedDevices) { int rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE); Log.d(TAG, device.getName()); } } if(BluetoothDevice.ACTION_FOUND.equals(action)) { BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); String uuid = intent.getStringExtra(BluetoothDevice.EXTRA_UUID); int rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE); Log.d(TAG, device.getName()); } } }
另外我想要每个找到的设备的rssi值,但请忽略语法