Search code examples
androidandroid-pendingintentandroid-alarmsandroid-broadcast

Android: PendingIntent sends broadcast initially, how to not broadcast initially?


The PendingIntent sends a broad cast when the method getBroadcast is called.

AlarmManager alarmManager = (AlarmManager)this.getSystemService(ALARM_SERVICE);                    
Intent alarmIntent = new Intent(Constants.ALARM_ACTION);    
PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);

alarmManager.set(AlarmManager.RTC_WAKEUP, getMidnight()
              .getTimeInMillis(), mPendingIntent);

I want the broadcast to only be sent when the alarm goes off not when getBroadcast is called, but the alarm requires a pending intent. Any ideas?


Solution

  • FIGURED IT OUT:

    In the API Documentation - If the time occurs in the past, the alarm will be triggered immediately.