title: How can I get the Intent extras for a PendingIntent that is already pending?
body: <p>I have scheduled a <code>PendingIntent</code> with <code>AlarmManager</code>.  When the <code>AlarmManager</code> delivers the <code>Intent</code>, I am able to <code>getExtras()</code> all the data that I originally sent.</p>
  
  <p>However, sometimes I get additional data that I want to pass with the <code>Intent</code>, before the <code>AlarmManager</code> fires.  My thought was, I would just get the <code>Intent</code> like I was going to cancel it, but then after cancelling it, update the extras and reschedule it with the <code>AlarmManager</code>, like this:</p>
  
  <pre><code>Intent i=new Intent(this, MyReceiver.class);
  Bundle b = i.getExtras();
  PendingIntent pi=PendingIntent.getBroadcast(this, id,i, 0);
  if (b == null) b = i.getExtras(); // in case I can't get it before calling getBroadcast
  // now add a key to b, put it in a new intent, schedule it, and cancel the old one?
  </code></pre>
  
  <p>I'm calling <code>getBroadcast()</code> with the same id as I schedule it with earlier.  The only problem is, when I call <code>getExtras()</code> it always returns null.  This seems to be kind of the reverse of the problem I have seen frequently where an <code>Intent</code> will be cached and that is not desired.  In this case I actually want to get the cached <code>Intent</code> and get the value for it, and since the <code>Intent</code> is pending it should still be there.</p>
  
  <p>How do I do this?</p>
  
  <p>A couple of ideas I have had and/or tried.  One revolves around the <code>Intent.fillIn()</code> function, could I perhaps use this to indicate that it should (or should not) overwrite the extras so that I can retrieve the original ones.</p>
  
  <p>Looking a bit further, I see that <code>PendingIntent</code> has <code>writeToParcel()</code>.  Can I use this to get access to the extras of the attached <code>Intent</code>? My attempt failed with <code>readBundle: bad magic number</code> exception on readParcel:</p>
  
  <pre><code>PendingIntent pi=PendingIntent.getBroadcast(this, id,i, 0);
  Parcel out = Parcel.obtain();
  pi.writeToParcel(out, 0);
  i.readFromParcel(out);
  </code></pre>
  
  <p>I suspect that maybe this is because I am outputting a <code>PendingIntent</code> but trying to read it back as an <code>Intent</code>.</p>
  
  <p>The other idea is that I could call send() on the <code>PendingIntent</code> to cause it to be immediately delivered, passing a new <code>Intent</code> with a new key to add.  Then in the handler I would have to iterate through all keys in the extras of the intent. It would then need to re-issue the <code>PendingIntent</code> to the <code>AlarmManager</code> if it wasn't time yet to do the actual processing.</p>