I hope that someone has an answer for me:
I wonder if it is possible (and common) to use the AlarmManager for directly starting an Activity. The documentation does not explain this explicitly. It only describes the usage of Broadcastreceivers.
If it is possible to start my Activity directy, where will I receive the Intent (onNewIntent)?
Many thanks
Jean-Pierre
Yes.
Using a
BroadcastReceiveris the most common scenario. It is required for_WAKEUPalarms, if you want the device to reliably wake up when the alarm goes off.Starting an activity from
AlarmManagershould be used for “alarm clock”-type applications, and little else. You have no idea what the user might be doing with the phone when your activity comes to the foreground, and they may get very angry with you if they feel that your intrusion is unjustified.By default, a new instance of the activity will be created. If you use
FLAG_ACTIVITY_CLEAR_TOPandFLAG_ACTIVITY_SINGLE_TOP, it will bring forward an existing instance of the activity, and you will get theIntentinonNewIntent().This sample project demonstrates using
AlarmManagerthis way. This sample project demonstrates user configurableActivity-or-Notificationwhen the alarm goes off. Both of these are relatively deep in a series of tutorials, and so the apps are a bit complex.