2011-06-25 236 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