How to increase brightness of screen on Android?

How could you increase the screen brightness in Android using a seek bar?

  • I would like to increase the brightness of the screen using a seek bar within my Android application, but I'm not sure how to do this. How can I add this functionality?

  • Answer:

    Using this you can set the screen brightness: WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = 100 / 100.0f; getWindow().setAttributes(lp); Now, as you want to implement progress bar like control, i would suggest you to implement SeekBar, so using this you can easily increase/decrease based on tracking value of seekbar. http://android-er.blogspot.com/2011/02/change-android-screen-brightness.html is the full example implemented using the SeekBar.

daffodils at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Use this to change the brightness (system-wide) ContentResolver cr = getContentResolver(); int brightness = Settings.System.getInt(cr,Settings.System.SCREEN_BRIGHTNESS); Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, brightness); WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = brightness / 255.0f; getWindow().setAttributes(lp); You may use http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/SeekBar1.html and call the above code in onProgressChanged(). Default values of progress range from 0 to 100.

Reno

You can change the screen brightness using the WindowManager.LayoutParams. Get the LayoutParams using getWindow().getAttributes() then set the field screenBrightness to a number between 0 to 1 (0 dark, 1 bright) and then call getWindow().setAttributes() with your modified LayoutParams object.

Jong

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.