Reputation: 8959
I had a few problems with my alarm that are in a another thread here if anyone could help but anyway here is a new question. If I set an alarm using my app, say for 5 minutes from now, and then close the app, how would I code it so that my app activity comes back to the front?
This is basically the same as the clock app already on most android phones. I'm doing this to allow the user to stop the alarm. Would I be right in saying that I would have to modify my existing code to, when the alarm is run, launch a new intent to bring the activity to the front? Or can I simplify this and only have an alertdialog or something open instead of opening the entire app?
Any links would be appreciated
Thanks
Upvotes: 0
Views: 326
Reputation: 8641
Don't move your activity to the front automatically. It's as annoying as a pop-up ad! Do you really want to try to interrupt the user who's trying to look up a phone number?
Instead, use a Service. When you want to tell the user something, post a status bar notification. You can set up the notification to bring up an Activity when the notification is clicked.
Most alarms are implemented in a Service.
Upvotes: 1
Reputation: 822
Have you looked into the AlarmManager? http://developer.android.com/reference/android/app/AlarmManager.html. I've used it in the future to fire Intents for Notifications. The Notification can then open an Activity for the user when they select the Notification from the Android Notification Bar.
Upvotes: 0