2013-05-03 2 views
0

내 AlarmManger에 문제에 봉착를가는 :는 알람 관리기 전에 설정 시간

올바르게 (시간 9시 25분이 경과 때문에) 출력이 올바른 일일 추가 아직 알람 관리기가 방송에서 호출 다음 몇 초. 관련 스 니펫이 있습니다. 어떤 아이디어?

Calendar cal = Calendar.getInstance(); 
    cal.set(Calendar.HOUR_OF_DAY, 21); 
    cal.set(Calendar.MINUTE, 25); 
    cal.set(Calendar.SECOND, 0); 
    cal.set(Calendar.MILLISECOND, 0); 


    Intent intent = new Intent(this, NotificationReceiver.class); 
    NotificationReceiver instance = new NotificationReceiver(); 
    intent.setAction(instance.NOTIFICATION_SEND); 
    intent.putExtra("TYPE",instance.NOTIFICATION_TYPE_PROGRESS); 
    intent.putExtra("Ticker","Waiting for arrival."); 
    intent.putExtra("ID",1); 
    intent.putExtra("title","Check-In"); 
    intent.putExtra("message","A message"); 

    if(System.currentTimeMillis()>cal.getTimeInMillis()){ 
     if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY||cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY||cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY){ 
      cal.add(Calendar.DAY_OF_WEEK,Calendar.MONDAY); 
      Log.d("ALARMS","Set for monday."); 
     } 
     else{ 
      cal.add(Calendar.DATE,1); 
      Log.d("ALARMS","Set for tomorrow. "+cal.get(Calendar.DAY_OF_MONTH)); 
     } 
    } 
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 24332, intent, 0); 
    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); 
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),4000,pendingIntent); 

답변

1

는 해결 :

PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 24, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
관련 문제