Search code examples
androidwakelockandroid-wake-lock

BroadcastReceiver, Service and Wakelock


im receiving an intent in broadcast receiver and then i start service to do more work. now what if the device is sleep and this happen, do i have to get Wakelock (AlarmManger?), and why do i need it? does my service will stop running if the device goes to sleep without getting a wakelock.


Solution

  • now what if the device is sleep and this happen, do i have to get Wakelock (AlarmManger?), and why do i need it?

    If the device is asleep to begin with, you will not be "receiving an intent in broadcast receiver", because the device is asleep.

    do i have to get Wakelock (AlarmManger?), and why do i need it?

    You don't "need it", unless you want to ensure the device stays running while you complete some work.

    does my service will stop running if the device goes to sleep without getting a wakelock.

    Yes.