“ BroadcastReceiver”是否总是会中止“ ACTION_PAIRING_REQUEST”?

时间:2019-06-23 17:56:32

标签: java android bluetooth

我有BroadcastReceiver正在抓捕ACTION_PAIRING_REQUEST

    final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
    registrar.activeContext().registerReceiver(pairingRequestReceiver, filter);

我的广播接收器如下:

final private BroadcastReceiver pairingRequestReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        switch (intent.getAction()) {
            case BluetoothDevice.ACTION_PAIRING_REQUEST:
                final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                final int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.ERROR);
                Log.d(TAG, "Pairing request (variant " + pairingVariant + ") incoming from " + device.getAddress());
                //...
            default:
                break;
        }
    }
};

问题是,注册接收者总是会阻止Android显示默认的系统配对对话框。

正常吗?只有abortBroadcast才能阻止该对话框...

我现在该怎么办?像“转播”一样?

任何帮助将不胜感激。

0 个答案:

没有答案