Skip to content
Advertisement

Change the System Brightness Programmatically

I want to change the system brightness programmatically. For that purpose I am using this code:

JavaScript

because I heard that max value is 255.

but it does nothing. Please suggest any thing that can change the brightness. Thanks

Advertisement

Answer

You can use following:

JavaScript

In your onCreate write:

JavaScript

Write the code to monitor the change in brightness.

then you can set the updated brightness as follows:

JavaScript

Permission in manifest:

JavaScript

For API >= 23, you need to request the permission through Settings Activity, described here: Can’t get WRITE_SETTINGS permission

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement