Service, WakeLock

后端 未结 2 578
我寻月下人不归
我寻月下人不归 2020-12-11 01:09

I am bit confused after going through the questions & answers in Stackoverflow about WakefulIntentService. I just would like to get some knowledge on this t

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-11 01:31

    What I am hearing from this forum, the service might turn off as soon the device goes to asleep. Is that true?

    Yes.

    In my case, it works always

    Then something else on your device is keeping the device from falling asleep. Perhaps use adb shell dumpsys power to see what WakeLocks are outstanding.

    What is the need of WakeFulIntent Service? When do we need to use WakefulIntentService?

    The device may fall asleep if the user is inactive and nothing is keeping the device awake. A WakeLock is used to ensure the device stays awake. For transactional-type work (e.g., downloading a file), WakefulIntentService combines an IntentService and a WakeLock to make keeping the device awake as long as necessary (and only as long as necessary) relatively easy.

    WakefulIntentService is not suitable for use with services that need to run indefinitely, such as a music player. For those, manage your own WakeLock.

提交回复
热议问题