1. Download our Official Android App: Forums for Android!

Apps NODE: AlarmManager, PowerManager.WakeLock and asynchronous call?

Discussion in 'Android Development' started by Imo_nac_, Feb 24, 2016.

  1. Imo_nac_

    Imo_nac_ Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Feb 24, 2016

    Feb 24, 2016
    1
    0
    5
    Hi
    I have a class called AlarmHandlerAndReceiver (extends BroadcastReceiver) that has a method to set the AlarmManager, another one to cancel AlarmManager and nother one to reschedule AlarmManager and sure the onReceive

    When onReceive takes place I acquire a PowerManager.WakeLock, send an intent to the app service then i ReScheduleAlarm and then release PowerManager.WakeLock

    This means that i want to execute a take (intent) in the service in a periodic manner, say from minute to minute.

    So my question is:

    When the onreceive takes place i use a PowerManager.WakeLock in order to avoid device fall asleep to be possible to reschedule the alarm again.
    However, the task call (on the service) is asynchronous (Intent) and in the meanwhile the PowerManager.WakeLock is released in the AlarmHandlerAndReceiver class.

    What hapens if the service task is still running and the device fall asleep?
    Is it needed to protect this? Should i make a synchronous task call (via application class?)

    Thanks a lot

    Alex
     

    Advertisement

Share This Page

Loading...