prevent mobile from going into sleep mode when app is running

后端 未结 3 941
礼貌的吻别
礼貌的吻别 2021-01-18 04:52

I want to prevent Android Mobile from going into sleep mode when my threads are sending HTTP request. as what happened while threads are doing HTTP calls mobiles goes to sle

3条回答
  •  滥情空心
    2021-01-18 05:08

    You need a WakeLock. There are different kinds of wake locks so be sure to select the least aggressive one that meets your needs. In particular it sounds like you need a Partial Wake Lock.

    Partial Wake Lock - Wake lock that ensures that the CPU is running. The screen might not be on.

    Also, make sure you add the permission android.permission.WAKE_LOCK to your manifest. And finally be double sure to Release your lock when you are done.

提交回复
热议问题