我想在列表视图中提供可用的蓝牙设备。我只能使用" Bt_adapter.getBondedDevices()"来配对设备。 。但我想只提供可用的设备。 我也尝试过intent.getParceableExtra()但它没用。
答案 0 :(得分:0)
您希望将BluetoothAdapter#startDiscovery()
与已注册的IntentFilter
例如:
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
bluetoothAdapter.startDiscovery();
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, filter)
其中mReceiver是BroadcastReceiver:
mReceiver = new BroadcastReceiver(){
public void onReceive(Context context, Intent intent){
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
}
};