androidandroid-activitywakeuponresume

How to handle Android activity lifecycle on wake up (alarm app)


I'm having a couple of problems with an alarm app I am developing.

The first thing that I think is a bit weird is that when an alarm goes of and wakes the phone up. These things happend.

oncreate
onresume
onpause
onresume

Why are they run in that order? The last two should not be called? And this is what's causes me big trouble, because when i press home or back on the phone, onPause is run, which I want to call finish() from. And that part works as it should, but that does not work when the phone wakes upp from sleep bacause of the onPause call...

Any ideas?


Solution

  • I would suggest you look at how the official alarm application handles the events: https://android.googlesource.com/platform/packages/apps/DeskClock