1
我有一段代碼被調用一次。然而,通知會在每2小時後觸發,因爲我希望它在2天后觸發。我嘗試了所有選項,但仍然無法正常工作報警管理器 - 每2小時後觸發
public int setAlarm(){
Calendar Calendar_Object = Calendar.getInstance();
/*
Calendar_Object.set(Calendar.MONTH,6);
Calendar_Object.set(Calendar.YEAR, 2013);
Calendar_Object.set(Calendar.DAY_OF_MONTH, 18);*/
// MyView is my current Activity, and AlarmReceiver is the
// BoradCastReceiver
Intent myIntent = new Intent(Splash.this, TimeAlarm.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,
0, myIntent, PendingIntent.FLAG_CANCEL_CURRENT);
long wkupTime = Calendar_Object.getTimeInMillis() + 36000;
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
// Log.w("alarm set for " , Calendar_Object.getTime().toString());
/*
* The following sets the Alarm in the specific time by getting the long
* value of the alarm date time which is in calendar object by calling
* the getTimeInMillis(). Since Alarm supports only long value , we're
* using this method.
*/
// alarmManager.setRepeating(AlarmManager.RTC, Calendar_Object.getTimeInMillis(),1000 *24*3600,
// pendingIntent);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, wkupTime , 172800000, pendingIntent);
return 0;