Two cases
The first case is:
Click notification--> to enter secactivity ---back--- exit the app
Pendingintent contentintent = pendingintent.getactivity (context, 0, intent, pendingintent.flag_cancel_current);
Second case:
Click notification--> to enter secactivity ---- back to mainactivity -->back and exit the app
Need to add intent array, here is two units, so first Open is secactivity (intent[1]),
You need to set properties on the specified activity in manifest
<android:name= ". Secactivityl" android:launchmode= " Singletask " android:taskaffinity=" " android:excludefromrecents = "true"></activity>
Pendingintent provides a static method Getactivities, which allows you to set a intent array to specify a series of activity.
intent[] Makeintentstack (context context) { new intent[2]; intents[0] = intent.makerestartactivitytask (new componentname (context, Com.example.notificationtest.MainActivity. class )); intents[New Intent (context, com.example.notificationtest.SubActivity. Class); return intents;}
One of the things to note is the Intent.makerestartactivitytask method, which is used to create the activity stack's root activity
Next, create and display the notification:
voidshownotification (Intent Intent) {Notification Notification=NewNotification (R.drawable.status_icon,Title at the top of the message Bar, System.currenttimemillis ()); Pendingintent contentintent=Pendingintent.getactivities ( This, 0, Makeintentstack ( This), pendingintent.flag_cancel_current); Notification.setlatesteventinfo ( This, "Drop-down Message Bar title", "Message Content", contentintent); Notification.flags|=Notification.default_all; Mnm.notify (1, notification);}
ANDROID Response Notification Event