Passing arguments to a BroadcastReceiver through an Intent in Android
<p>I have an application, which sets an alarm using AlarmManager, which starts another Activity when it goes off.  The AlarmManager takes a PendingIntent and spawns a BroadcastReceiver class when the specified time comes.  I'm wondering whether there is any way that I can pass arguments to this BroadcastReceiver through the Intent object which goes into PendingIntent?</p>

<p>Basically what I'd like to do is something like this:</p>

<p>Intent my_intent = new Intent(this, BroadcastService.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, my_intent, 0);</p>

<p>my_intent.putExtra("arg1", arg1);</p>

<p>AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);</p>

<p>alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000), pendingIntent);</p>

<p>and I'd like to be able to retrieve arg1 in the BroadcastReceiver's onReceive(Context, Intent) method.  I figured that the local variable my_intent would be the second parameter passed on to onReceive by the PendingIntent, but apparently that's not quite right.  Is it possible to pass parameters between an Activity and a BroadcastReceiver in this fashion (using Intent.putExtra()) or should I use a ContentProvider instead?</p>

<p>Thanks!</p>

<p>Iva</p>
