Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had the same problem.</p> <p>Two solutions:</p> <p>here, brightness =<code>(int) 0 to 100 range</code> as i am using progressbar</p> <p><strong>1 SOLUTION</strong></p> <pre><code>float brightness = brightness / (float)255; WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = brightness; getWindow().setAttributes(lp); </code></pre> <p><strong>2 SOLUTION</strong></p> <p>I just used dummy activity to call when my progress bar <code>stop</code> seeking.</p> <pre><code> Intent intent = new Intent(getBaseContext(), DummyBrightnessActivity.class); Log.d("brightend", String.valueOf(brightness / (float)255)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //this is important //in the next line 'brightness' should be a float number between 0.0 and 1.0 intent.putExtra("brightness value", brightness / (float)255); getApplication().startActivity(intent); </code></pre> <p>Now coming to the DummyBrightnessActivity.class</p> <pre><code> public class DummyBrightnessActivity extends Activity{ private static final int DELAYED_MESSAGE = 1; private Handler handler; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); handler = new Handler() { @Override public void handleMessage(Message msg) { if(msg.what == DELAYED_MESSAGE) { DummyBrightnessActivity.this.finish(); } super.handleMessage(msg); } }; Intent brightnessIntent = this.getIntent(); float brightness = brightnessIntent.getFloatExtra("brightness value", 0); WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = brightness; getWindow().setAttributes(lp); Message message = handler.obtainMessage(DELAYED_MESSAGE); //this next line is very important, you need to finish your activity with slight delay handler.sendMessageDelayed(message,200); } } </code></pre> <p>don't forget to register DummyBrightnessActivity to manifest.</p> <p>hope it helps!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload