2
votes

My app detects whether Bluetooth is disabled and triggers a system alert dialog (to enable Bluetooth) through:

startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), 1711);

It is, however, also possible to enable Bluetooth through the notification bar and when Bluetooth is enabled there the system alert dialog is still shown.

Can I somehow dismiss this dialog or remind Android to finish the activity and return the result (which is successful in this case) when the user enables Bluetooth through the notification bar?

1
You should see a system pop-up for permission to use bluetooth. what version of Android do you use ? please add a screenshot of the pop-up - matdev
The popup is Android native and localized. It says (roughly translated to English): "X requests Bluetooth to be turned on" with two options: Cancel/Dismiss and Allow - Alix

1 Answers

0
votes

No it is not possible to programmatically dismiss the Bluetooth system alert dialog you see on Android 9+

However, you can avoid the system alert dialog by enabling Bluetooth programatically, at least on Android 8 and less:

final BluetoothAdapter ba = BluetoothManagerCompat.getAdapter(yourActivity);
ba.enable();