views:

36

answers:

2

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...

I would appreciate if someone could point me in the right direction, because I'm stuck.

Thanks in advance.

A: 

Do you really want to call finish() in onPause()? onPause() is called when the current activity is not in the foreground any more. Maybe you want to call finish() in your onStop() method instead. See the Activity lifecycle for details.

mreichelt
A: 

I would suggest you look at how the official alarm application handles the events: http://android.git.kernel.org/?p=platform/packages/apps/DeskClock.git;a=summary

Christian