2

I have set one alarm in repeated mode for every 24 hours. So Alarm receiver should be call on the time set only once but it calls repeatedly. Why?

Here is I am attached my code to set alarm:

        AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        Intent objIntent = new Intent(this, PedometerAlarmReciever.class);
        PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, objIntent, 0);

        // Set the alarm to start at 21:32 PM
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.HOUR, 11);
        calendar.set(Calendar.MINUTE, 20);
        calendar.set(Calendar.AM_PM, Calendar.AM);

        // setRepeating() lets you specify a precise custom interval--in this case,
        // 1 day
        alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
                AlarmManager.INTERVAL_DAY, alarmIntent);
halfer
  • 19,824
  • 17
  • 99
  • 186
Anil Ravsaheb Ghodake
  • 1,587
  • 2
  • 27
  • 45
  • Try adding [`FLAG_UPDATE_CURRENT`](https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_UPDATE_CURRENT) as the last parameter of `PendingIntent.getBroadcast()` – A.A. Jan 13 '17 at 07:57
  • @AmrAbed This flag is used to indicate that intent is different for every call.But,in my case I need to execute receiver only once – Anil Ravsaheb Ghodake Jan 13 '17 at 08:57

0 Answers0