问题
Can I get the Intent from a PendingIntent?
Here is the scenario:
- I create an
Intent(let's call itmyIntent) - I put some Extra information with a String (call it
myInfo) - I create a
PendingIntent(myPendingIntent) usingmyIntent - I set an alarm using the
AlarmManagerandmyPendingIntent - At a later stage I get hold of the PendingIntent using
PendingIntent.getBroadcast - At that point I want to read
myInfofrommyIntentwhich is inmyPendingIntent
Is this possible? By looking around Google, I am coming close to the conclusion that this is not possible.
回答1:
Is this possible?
Nope. PendingIntent is a write-only interface. You can replace the Intent, but you cannot read it.
回答2:
It's possible since 4.2.2 using reflection. Take a look at this answer, there's complete solution to obtain Intent from PendingIntent.
来源:https://stackoverflow.com/questions/23725035/how-to-get-intent-from-pendingintent