2011-07-05 68 views
0

使用以下代码,我希望通知在点击时消失。不要开始任何活动。我怎么做?如何不从通知开始活动

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); 

回答

0

我知道我以前采取的一种方法是根本不填写关于用于创建PendingIntent的Intentu的任何信息。在你的例子中,你只需删除传递给构造函数的“intent”的参数。

我不完全确定您是否可以将null传递给setLatestEventInfo作为挂起的意图,但如果您不能,我提出的解决方案应该可以工作。