wwjdm
wwjdm

Reputation: 2596

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?

Upvotes: 0

Views: 96

Answers (1)

wwjdm
wwjdm

Reputation: 2596

FIGURED IT OUT:

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

Upvotes: 0

Related Questions