Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 278
Lefteris Avatar asked May 18 '14 17:05

Lefteris


People also ask

What is the difference between intent and PendingIntent?

In conclusion, the general and main difference between Intent and PendingIntent is that by using the first, you want to start / launch / execute something NOW, while by using the second entity you want to execute that something in the future.

What is request code in pending intent?

1- requestCode is used to get the same pending intent later on (for cancelling etc) 2- Yes, they will get override as long as your specify the same Receiver to your Intent that you specify on your PendingIntent.

Which method creates PendingIntent objects?

To perform a broadcast via a pending intent so get a PendingIntent via PendingIntent. getBroadcast(). To perform an activity via an pending intent you receive the activity via PendingIntent. getActivity().


1 Answers

Is this possible?

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

like image 98
CommonsWare Avatar answered Oct 05 '22 22:10

CommonsWare