views:

174

answers:

1

Hi, I'm new to Android development, so I might be missing something obvious. I want to launch an activity when the user's phone clock hits a specified time (similar to an alarm). However, I'm not sure how I would go about doing this as constant polling of the clock seems inefficient and a waste of resources. Do I need to capture broadcast events from the lclock, or use PendingIntents? If someone could point out some SDK methods/services I should read about, it would be much appreciated. Thanks.

+5  A: 

Take a look at the docs for android.app.AlarmManager.

This class allows your application to schedule PendingIntents for broadcast at specific times, which sounds like exactly what you're looking for. Just schedule a PendingIntent that launches the desired application.

Be aware that when your alarm fires, the phone will be prevented from sleeping until (and only until) onReceive() finishes executing. If you need to keep the phone awake longer, you may need to implement your own wake lock.

Trevor Johns
Thanks for the reply. AlarmManager looks like what I need. I think I saw it before, but read over it thinking that it was literally for the Alarm system. I'll play around with this and hopefully I'll get something working :). Thanks!
keyboardP