How can I avoid or dismiss Android's Bluetooth pairing notification when I am doing programmatic pairing?

前端 未结 3 1806
陌清茗
陌清茗 2020-11-29 16:52

I have an app where I am programmatically controlling Bluetooth pairing and unpairing. I can pair before connection and unpair afterwards. The reason I need to do this is

3条回答
  •  甜味超标
    2020-11-29 17:36

    Do this in the PAIRING_REQUEST notification event:

    BluetoothDevice localBluetoothDevice = (BluetoothDevice)intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE");
    
    Class localClass = localBluetoothDevice.getClass();
    Class[] arrayOfClass = new Class[0];
    localClass.getMethod("cancelPairingUserInput", arrayOfClass).invoke(paramBluetoothDevice, null)).booleanValue();
    

    But you gotta tell me how did you pair your remote device without the user to enter Passkey/PIN? off course, you know the PIN for the remote device which is trying to pair to your device but how did you provide that PIN to the remote device.

提交回复
热议问题