3

I want a dialog that adjusts brightness of the screen using SeekBar.

How to display custom dialog with SeekBar that adjusts brightness of screen?

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Vaibhav Jani
  • 12,428
  • 10
  • 61
  • 73
  • 3
    You can't adjust the screen brightness anymore at a global level; note this SO question http://stackoverflow.com/questions/6158628/android-short-screen-brightness-code – Aaron McIver Sep 08 '11 at 04:42
  • yeah.. it will apply only to your window. – Ron Sep 08 '11 at 07:51

3 Answers3

6

You can use this API. This will change screen brightness of your window and not of the whole system.

        // Make the screen full bright for this activity.
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.screenBrightness = 1.0f;

        getWindow().setAttributes(lp);
Ron
  • 24,175
  • 8
  • 56
  • 97
2

This code snippet should help you

pdlg = ProgressDialog.show(getParent(), "Loading...", ""); 
WindowManager.LayoutParams lp = pdlg.getWindow().getAttributes();
p.dimAmount=0.0f;        //Dim Amount
pdlg.getWindow().setAttributes(lp);  //Applying properties to progress dialog
pdlg.dismiss(); //Dismiss the dialog
Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
harish
  • 255
  • 1
  • 3
  • 13
1

Hey you can set the system brightness like this:

 //Set the system brightness using the brightness variable value
System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
//Get the current window attributes
LayoutParams layoutpars = window.getAttributes();
//Set the brightness of this window
layoutpars.screenBrightness = brightness / (float)255;
//Apply attribute changes to this window
window.setAttributes(layoutpars);

Or you may refer on this complete tutorial

dondondon
  • 881
  • 8
  • 4