In an android application, I have a screen that requires that bluetooth is enabled, if it is disabled, the part of the code below asks the user to enable it:
final BluetoothManager bluetoothManager =
(BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
((MainActivity) context).startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
Up until then, when bluetooth is disabled, the native Android screen asks you to enable it.
"The application is requesting permission to enable Bluetooth. Allow?"
If the user presses "YES" it enables bluetooth, however, I did not find how to handle it if the user pressed "NAO".