Using the following code, I would like to have the notification to just disappear when clicked. Don’t start any activity. How do I do that?
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification n = new Notification(R.drawable.icon, "hello", System.currentTimeMillis());
n.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(ctx, NotifyActivity.class);
PendingIntent i = PendingIntent.getActivity(ctx, 0, intent, 0);
n.setLatestEventInfo(ctx, "title", "content", i);
nm.notify(1, n);
I know one approach I have taken in the past is to simply not fill out any information on the Intentu used to create the PendingIntent. In your example, you would just remove the arguments passed to the constructor for “intent”.
I’m not entirely sure if you can just pass null to setLatestEventInfo for the pending intent, but if you can’t, the solution I presented should work.