Activity triggered by a click on a Notification

Posted by Zelig63 on Stack Overflow See other posts from Stack Overflow or by Zelig63
Published on 2012-10-12T15:30:56Z Indexed on 2012/10/12 15:37 UTC
Read the original article Hit count: 262

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-intent