Reputation: 5522
I'm making a simple reminder app on android.
I've got a date such as 27-06-2011 (DD-MM-YY) and I wish to create an alarm at this date (at 12:01AM).
I know this is possible, but how easy is it?
Upvotes: 0
Views: 91
Reputation: 38168
Easy answer from google :
Intent intent = new Intent(this, RepeatingAlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), 10 * 1000, pendingIntent);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
If you need to use the date you mentionned, create a Time objet, set the fields using its constructor and use time.toMillis( false); to get the right paramter for the alarm manager.
Regards, Stéphane
Upvotes: 1