Lefteris
Lefteris

Reputation: 885

How to get Intent from PendingIntent

Can I get the Intent from a PendingIntent?

Here is the scenario:

  1. I create an Intent (let's call it myIntent)
  2. I put some Extra information with a String (call it myInfo)
  3. I create a PendingIntent (myPendingIntent) using myIntent
  4. I set an alarm using the AlarmManager and myPendingIntent
  5. At a later stage I get hold of the PendingIntent using PendingIntent.getBroadcast
  6. At that point I want to read myInfo from myIntent which is in myPendingIntent

Is this possible? By looking around Google, I am coming close to the conclusion that this is not possible.

Upvotes: 19

Views: 12860

Answers (2)

tomrozb
tomrozb

Reputation: 26281

It's possible since 4.2.2 using reflection. Take a look at this answer, there's complete solution to obtain Intent from PendingIntent.

Upvotes: 4

CommonsWare
CommonsWare

Reputation: 1007624

Is this possible?

Nope. PendingIntent is a write-only interface. You can replace the Intent, but you cannot read it.

Upvotes: 19

Related Questions