I wrote this code
WindowManager.LayoutParams params = getWindow().getAttributes();
params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON;
params.screenBrightness = 0.1F;
getWindow().setAttributes(params);
SystemClock.sleep(5000);
TextView Text01 = (TextView) findViewById(R.id.Text1);
Text01.setText("Hello");
to set the screen brightness and then, after 5 seconds, it displays text. The problem is that it waits 5 secs then Android dims the screen and output the text at the same time. Why it does not work sequentially? Thanks