Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep Screen Bright While In AsyncTask

I'm using this code in my AsyncTask to make sure the screen stays bright while the AsyncTask runs:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

However, I don't want the screen to be forced to be bright after the AsyncTask has ran. How can I essentially 'undo' or 'turn off' that option?

like image 979
Mxyk Avatar asked Dec 02 '25 16:12

Mxyk


1 Answers

In your onPostExecute method in your AsyncTask call

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

See this question for more help.

like image 74
Jack Avatar answered Dec 05 '25 06:12

Jack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!