Android : How to launch Pending intent from another activity with extras

androidandroid-intentandroid-pendingintentextra

I am facing some problem with pending intents. I have set some Pending Intents using Notification Manager. These notification launch an activity when user click on them. I put some extras with Intent used in pending intent. This works OK with notification click.

Notification notification = new Notification(icon, tickerText, when);
    Context context = getApplicationContext();

Intent intentOptionDialog = new Intent(Safety_Check_Service.this, Dialog_Safety_Check.class);
    intentOptionDialog.putExtra("startID",startId);
    intentOptionDialog.putExtra("CheckInID", CheckInId);
    intentOptionDialog.putExtra("Frequency", Frequency);
    intentOptionDialog.putExtra("flagFirstShedule", true);

        stopID = (startId + 17);

    intentOptionDialog.putExtra("stopID", stopID);

    PendingIntent contentIntent = PendingIntent.getActivity(Safety_Check_Service.this, DIALOG_ID, intentOptionDialog, 0);

But my problem is that I want to launch these pending intents from another activity. The pending intents are created. How can I lauch these pending intents from another activity and how can I get Extras that was set with the pending intent?

Please help me.

Best Answer

I think you have 2 pieces here:

  1. Try using the answer I gave at Keeping track of sms sent in Android: add the FILL_IN_SELECTOR flag when you create the PendingActivity to force it to carry the extras with it.
  2. Once you have the PendingIntent, you can just call the send method to fire it.