Android notification click, run the main intent?
Hy!
public static void addNotification(String sAppname, String sDescription) {
NotificationManager notifManager = (NotificationManager) mycontext.getSystemService(NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.icon, sDescription, System.currentTimeMillis());
Intent i = new Intent (mycontext, mStart.class)
.setAction(Intent.ACTION_MAIN)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
开发者_运维知识库 PendingIntent contentIntent = PendingIntent.getActivity(mycontext, 0, i, 0);
note.setLatestEventInfo(mycontext, sAppname, sDescription, contentIntent);
notifManager.notify(NOTIFY_ID, note);
}
mStart is my first activity
if i click on the notification this code is "re-create" the intent, and show up a new one.
i dont want this. i d like to show up the existing main intent. how to?
The solution is:
in manifest file add the following: singleTask="true"
精彩评论