1

I'm new to android and trying to programmatically connect a BluetoothDevice. Device has a PIN. Connecting to device is in another thread than UI. So far I have followed example from How to programmatically pair a bluetooth device on Android.

On BluetoothDevice.ACTION_PAIRING_REQUEST I convert String to byte[] and do a setPin call. the pairing dialog pops out and dissapear. Any actions like

       Method createBondMethod1 = device.getClass().getMethod("cancelPairingUserInput");  
       Boolean returnValue2 = (Boolean) createBondMethod1.invoke(device); 

have failed on setPin. BluetoothDevice.ACTION_PAIRING_REQUEST is triggered when device.createBond() is called.

The question is how can I hide Pairing dialog?

Thanks.

Community
  • 1
  • 1
user3648165
  • 11
  • 1
  • 3

1 Answers1

2

The only solution I've found is to dimiss all system dialogs by using:

    getContext().sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

But the problem is to capture the right moment to dimiss it, and the trusted solution to this problem has to be to not show that dialog,... but I think the only solution to that will could on modifying the bluetoothDialog apk in the system for not showing that intent.

If anyone knows a better solution, please let us know!

Luigi
  • 21
  • 6