0

GOOD DAY! im new in android programming, just want to ask this question.

adjusting the brightness of lcd/led to minimum in just 1 button? i am planning to make an application to save battery life for my own device. if it is possible please teach me how thank you!

  • Take a look here http://stackoverflow.com/questions/18312609/change-the-system-brightness-programmatically – vishnus Sep 03 '15 at 04:13
  • @vishnus im sorry kinda new in java and android programming so maybe i am missing the basics. i barely understand the post with the marked answer but i don't know how to put it on a button. – kim caboteja Sep 03 '15 at 04:35

1 Answers1

1

Android Brightness Reference Developer link

0 = dark bright.

1 = full bright.

    click.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
            layoutParams.screenBrightness = 0;        //brightness level
            getWindow().setAttributes(layoutParams);
        }
    });
Iamat8
  • 3,888
  • 9
  • 25
  • 35
  • i added your code to my onclick and there is no error but my problem now is it doesnt auto generate the apk fil on bin folder. maybe there is missing? – kim caboteja Sep 03 '15 at 05:22
  • i cleaned the project then it regenerates the apk from the bin file. thank you! one more question, when i close the app the brightness turns back to normal, what should i do to make it stay in minimum even app closed? – kim caboteja Sep 03 '15 at 05:38