简体   繁体   中英

keep android screen from dimming while activity is running

For my android app, I want to keep the screen from dimming while certain activities (eg CatActivity) are in the resume state. Does anyone know how to do that? is there a way to declare so in the manifest or in the activity itself?

UPDATE

I found the answer:

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

Is there a way to turn it off? I don't see a removeFlags method.

要删除该标志,只需调用clearFlags()方法:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM