I am wondering if the following is possible in android. I want to have my application do a certain task whenever the phone get awoken. Whenever some other application acquires a wake lock to do it's task, I want my application to do something of its own.
Can I get notified through an intent using a broadcast receiver about this event? If so, what will happen if that other application finishes before my task ends?
The reason I'm asking is that I don't want to wake the phone up to do my task and affect the battery life. I want to take the opportunity of the wake lock to do my thing.
You could use AlarmManager with RTC or ELAPSED_REALTIME type.
http://developer.android.com/reference/android/app/AlarmManager.html#RTC
The device is not woken up when your alarm goes off. the next time phone is awake your alarm is triggered.