2016-09-20 85 views
1

我想在用戶定義時間安排重複警報。對於我使用下面的代碼PutExtras與重複警報器

AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); 
      Intent intent = new Intent(this, AlarmReceiver.class); 
      intent.putExtra("id", id); 
      intent.putExtra("ontime", flag_ontime); 

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, 
        intent, PendingIntent.FLAG_UPDATE_CURRENT); 

am.setRepeating(AlarmManager.RTC_WAKEUP, 
         SystemClock.elapsedRealtime() +calendar.getTimeInMillis(), 
         AlarmManager.INTERVAL_DAY, pendingIntent); 

一切工作正常...我還報警開火所需的時間,但在我的接收器,我總是得到沒有通過一個

AlarmReceiver.class

意圖只是默認值
long id = intent.getLongExtra("id", -1); 
boolean ontime = intent.getBooleanExtra("ontime", false); 

這裏ID總是-1,準時是假的....請幫我

回答

0

以及我現在我已經解決了這個利用alarmmanager setExact()方法d每次事件發生時,我按照其重複時間重新安排警報......尋找電池解決方案