0

From a Service, I trigger a Notification which, when clicked, has to launch an Activity. To do this, I use the following code :

    notification=new Notification(icone,title,System.currentTimeMillis());
    intent=new Intent(getApplicationContext(),myActivity.class);
    intent.putExtra("org.mypackage.name",true);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    pendingIntent=PendingIntent.getActivity(getApplicationContext(),0,intent,PendingIntent.FLAG_ONE_SHOT);        notification.setLatestEventInfo(getApplicationContext(),title,"Message",pendingIntent);
    notification.flags|=Notification.FLAG_AUTO_CANCEL;
     ((NotificationManager)contexte.getSystemService(Context.NOTIFICATION_SERVICE)).notify("label,0,notification);

When I click on the Notification, the Activity is correctly launched. But it's Intent doesn't contain the extra boolean added with the line intent.putExtra("org.mypackage.name",true);.

Does anyone have an idea of this behaviour?

I can add that I use Android 4.

Thanks in advance for the time you will spend trying to help me.

Zelig63
  • 1,592
  • 1
  • 23
  • 40
  • in my experience sometimes intent doesn't send other type. pls, check intent.putExtra("org.mypackage.name", "true"); and in myActivity getIntent().getStringExtra("org.mypackage.name"); – Jamshid Oct 12 '12 at 15:36

1 Answers1

1

This post says that if you don't set an Action on your Intent that the extras won't be passed along. SO you should try that.

Community
  • 1
  • 1
CaseyB
  • 24,780
  • 14
  • 77
  • 112