2011-05-05 106 views
0

我想在android中設置多重鬧鈴。請幫助我完成這項任務。android多重鬧鈴設置

感謝&問候 爬完帕塔克

+0

請不要在帖子的電子郵件聯繫方式:http://meta.stackexchange.com/questions/89965/what-to-do-when-questioner-posts-email-address-for - 響應 – forsvarir 2011-05-05 21:03:29

+0

我想知道是否有任何代碼段的多個警報...我成功實現了單一的警報,但是當我嘗試多個使用日曆時,沒有人在應用程序中設置,所以如果有任何代碼可用於多個報警 – 2011-05-06 20:40:43

回答

-1

您可能需要使用多個意圖。 在這個例子中,我設置了兩個警報,一個10秒後,另一個15秒後。 希望它有幫助。

// set first alarm 
Calendar time1 = Calendar.getInstance(); 
time1.add(Calendar.SECOND, 10); 
// set intent to be fired 
PendingIntent sender1 = PendingIntent.getBroadcast(this, 1, new Intent(this, AlarmReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT); 
// set alarm manager 
AlarmManager alarm1 = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); 
alarm1.set(AlarmManager.RTC_WAKEUP, time1.getTimeInMillis(), sender1); 

// set second alarm 
Calendar time2 = Calendar.getInstance(); 
time2.add(Calendar.SECOND, 15); 
// set intent to be fired 
PendingIntent sender2 = PendingIntent.getBroadcast(this, 2, new Intent(this, AlarmReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT); 
// set alarm manager 
AlarmManager alarm2 = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); 
alarm2.set(AlarmManager.RTC_WAKEUP, time2.getTimeInMillis(), sender2);