Prevent screen lock on dimming/standby while using android app?

前端 未结 2 1755
耶瑟儿~
耶瑟儿~ 2021-01-14 09:52

I\'m developing an application and the last touch I need to put on it is preventing the screen to lock when the device goes into standby (screen off). The exact behavior as

相关标签:
2条回答
  • 2021-01-14 10:27

    writing the following code to your xml file will prevent the screen from locking

    android:keepScreenOn="true"
    
    0 讨论(0)
  • 2021-01-14 10:38

    In the onCreate of your activity after the setContentView use this:

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

    Not tried it myself.

    0 讨论(0)
提交回复
热议问题