I am designing an Android app in which I want to show a QR code using a button click. When clicking the button, it should show the QR Code with full device brightness, regardless of actual device brightness. And after hiding QR code, it needs to reset the actual device brightness.
I searched the Internet, and many sources say that you need to use the "WRITE_SETTINGS" permission to modify the system settings by an app. Also I read & see the app like Paytm, which increase screen brightness when showing a QR code and automatically sets the actual brightness once hiding QR code with "WRITE_SETTINGS".
I want to use device brightness like Paytm without "WRITE_SETTINGS" permission. If anything available like this, please let me know.
I tried to use it with "WRITE_SETTINGS" permission, if permission granted no pbm. But if I am not granted permission, I could not use full brightness when showing the QR Code.
To get device brightness:
Settings.System.putInt(this.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
brightness = Settings.System.getInt(this.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, -1);
To set device brightness:
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness);