I have a activity which is called from a AlarmManager. It is an alarm message.
When the Activity is called from the Key Guard, the lifecycle goes from onCreate -> onStart -> onResume -> onPause -> onStop and then goes back to onCreate -> onStart -> onResume.
Since it's a alarm activity, I have put the MediaPlayer.stop line inside the Activity's onStop, but now the alarm sound stops just after it starts.
If I put the MediaPlayer.stop inside onDestroy, I get the correct behavior, but if the user press the home button, the activity goes away and the sound keeps playing.
Anyone can tell why onPause and onStop are called during in this situation?
EDIT: After some investigation in the log, I found this line:
11-26 17:39:01.273: I/ActivityManager(385): Activity reported stop, but no longer stopping: ActivityRecord{41827a90 u0 net.xisberto.workschedule/.AlarmMessageActivity}