Keep Screen Bright While In AsyncTask

你说的曾经没有我的故事 提交于 2019-12-22 11:19:25

问题


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?


回答1:


In your onPostExecute method in your AsyncTask call

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

See this question for more help.



来源:https://stackoverflow.com/questions/7195423/keep-screen-bright-while-in-asynctask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!