2011-06-25 186 views
0

我正在android上做一个简单的提醒应用程序。Android闹钟问题

我有一个日期,如27-06-2011(DD-MM-YY),我希望在这个日期(上午12:01)创建一个闹钟。

我知道这是可能的,但它有多简单?

回答

1
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(); 

如果您需要使用您mentionned日期,创建时间OBJET,使用它的构造函数中设置的字段和使用time.toMillis(假);为警报管理员提供正确的参数。

Regards, Stéphane