0
我想通过蓝牙从另一个Android设备接收配对请求时触发某些东西,我在我的活动中注册了广播接收器,但它不起作用。任何人都知道如何做到这一点?如何使用广播接收机收听蓝牙配对请求?
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
Log.i("BLE Pairing Info", "111");
this.registerReceiver(bluetoothReceiver, filter);
bluetoothReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action)) {
BluetoothDevice dev = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Log.i("BLE Pairing Info",action);
//dev.setPairingConfirmation(true);
}
}
};
问题是什么? –