Android - how to toggle display backlight from activity

451 Views Asked by At

I have a special requirement with my Android tab (SM-T825) in which I need to programmatically turn on or off the display backlight but still be able to receive touch inputs. I tried various options as seen in multiple SO posts but none of them really works. I had the following code:

ContentResolver cResolver = getApplicationContext().getContentResolver();
Settings.System.putInt(cResolver, Settings.System.SCREEN_BRIGHTNESS, 0);

which only dims the screen, but not really turning it off. Is this really possible even on a rooted phone or with a custom ROM?

1

There are 1 best solutions below

0
Babu James On

I found the answer for this issue. I have to root the phone and write 0 to /sys/class/backlight/panel/brightness as root