PowerManager.PARTIAL_WAKE_LOCK android

前端 未结 2 1546
梦如初夏
梦如初夏 2020-12-02 02:38

I am very confused whether to acquire this wakelock. E.g. I have this type of code that is called from onReceive() of a BroadcastReceiever (CONNECT

2条回答
  •  [愿得一人]
    2020-12-02 03:18

    The answer by @paha misses an important point : IntentService is not enough. Between onReceive() ends and the IntentService is started the phone might fall asleep again. You need a (static) lock to bridge this gap - this is implemented in Mark Murpphy's WakefulIntentService

    So keep the AlarmManager and receiver but launch a WakefulIntentService from your onReceive().

    See:

    • Android deep sleep and wake locks
    • PowerManager wakelock not waking device up from service

提交回复
热议问题