Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8124369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:26:26+00:00 2026-06-06T06:26:26+00:00

My app is a simple Brightness Changer, that also changes System Brightness (what isn’t

  • 0

My app is a simple “Brightness Changer”, that also changes System Brightness (what isn’t to easy to implement :D).
I actually set up everything and its working fine… except for one little annoying thing… everytime the brightness changes the screen first “flashes” to the highest brightness (like 100% light) and after a half second or so, it changes to the right brightness.

Example: System Brightness should be 120: 1. Change to 255 (max.), adter half second change to 120.

Here is the code of my two classes. The Dummy class is used to “reset” the (necessary for applying brightness change.)

EDIT: btw. i think the problem is the “lp.screenBrightness = 100/100.0f;” in the dummyactivity. But it wont work without it :/


test.java

public class Test extends Activity
{
    SeekBar seekbar;
    TextView value;
    TextView debug;
    Button button1;
    Button button2;
    Button button3;

    public void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        value = (TextView) findViewById(R.id.textview2);
        debug = (TextView) findViewById(R.id.textview3);
        seekbar = (SeekBar) findViewById(R.id.seekbar);
        button1 = (Button) findViewById(R.id.button1);
        button2 = (Button) findViewById(R.id.button2);
        button3 = (Button) findViewById(R.id.button3);

        seekbar.setOnSeekBarChangeListener( new OnSeekBarChangeListener()
        {
            public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
            {
                // TODO Auto-generated method stub
                int brightness = progress+1;
                double b = brightness/2.55;
                double c = Math.round(b*100)/100;
                int percent = (int) c;
                if (percent==0) {
                    value.setText("Lightlevel: !MIN!");
                }else if (percent==100){
                    value.setText("Lightlevel: !MAX!");
                }else{
                    value.setText("Lightlevel: "+percent+"%");
                }
                debug.setText("int brightness: "+brightness+" / double b:"+b+" / double c: "+c+" / int percent: "+percent);
                Settings.System.putInt(getContentResolver(),Settings.System.SCREEN_BRIGHTNESS, brightness);
            }

            public void onStartTrackingTouch(SeekBar seekBar)
            {
                // TODO Auto-generated method stub
                Intent in = new Intent(Test.this,DummyBrightnessActivity.class);
                startActivity(in);
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }
        });


        button1.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Settings.System.putInt(getContentResolver(),Settings.System.SCREEN_BRIGHTNESS, 1);

                Intent in = new Intent(Test.this,DummyBrightnessActivity.class);
                startActivity(in);
            }

        });

        button2.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Settings.System.putInt(getContentResolver(),Settings.System.SCREEN_BRIGHTNESS, 127);

                Intent in = new Intent(Test.this,DummyBrightnessActivity.class);
                startActivity(in);
            }

        });

        button3.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Settings.System.putInt(getContentResolver(),Settings.System.SCREEN_BRIGHTNESS, 255);

                Intent in = new Intent(Test.this,DummyBrightnessActivity.class);
                startActivity(in);
            }

        });
    }
}

DummyBrightnessActivity.java

public class DummyBrightnessActivity extends Activity{

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.dummy);

        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.screenBrightness = 100/100.0f;
        getWindow().setAttributes(lp);

        Timer timer2 = new Timer();
        timer2.schedule(new TimerTask() {

           public void run() {

              finish();

           }

        }, 500);

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:26:28+00:00Added an answer on June 6, 2026 at 6:26 am

    Answering my own question for future use.

    The problem is really the lp.screenBrightness = 100/100.0f;. So i put some variable in the intent which has the right value of brightness, so i can make it like lp.screenBrightness = brightness;.

    I know this is kind of short, but if someone ever wants to know more about it,just ask in comment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a SeekBar in a simple flashlight app (that I'm learning
I developed one Simple app, which contains one textview.and my problem is that I
I have one simple app that suppose to get information from user and send
I have a simple app that will allow a user to tag a location.
i've a simple app that should show the device's location on a map. the
I have a simple app that has a NSStatusItem, which only displays an icon.
I have a simple app that allows the user to push a button that
I have developed a simple app that contains a UITableView that displays data, and
Consider a simple app server / database server setup. You want to set some
I have a simple app that reads internet resource and displays the information in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.