prevent mobile from going into sleep mode when app is running

后端 未结 3 940
礼貌的吻别
礼貌的吻别 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 05:27

    To prevent the phone from sleeping you can use a WakeLock but you should be careful when doing this to not kill the user's battery. If the phone goes to sleep does the user really care if your app finishes the requests it was making?

    You will also need the WAKE_LOCK permission.

提交回复
热议问题