I am trying to display a toast to the user and dim the screen to its minimum brightness after 5 seconds. But the screen didn't dim at all. Did I make any mistake in my codes? Please help.
Codes:
private void DimScreen()
{
Toast.makeText(StartActivity.this, "Dimming screen in 5 seconds, press Stop button to turn on the screen", Toast.LENGTH_SHORT).show();
handler.postDelayed(r, 5000);
}
private Handler handler= new Handler();
private Runnable r = new Runnable()
{
public void run()
{
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness=0.01f;
getWindow().setAttributes(lp);
}
};