private NotificationManager MyNotiManager = null;
public void SendNotification(String msg, int IconId, Bundle bundle, String title, int notiid)
{
if (MyNotiManager == null)
{
MyNotiManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
Intent notifyIntenet = new Intent("action_receive");
notifyIntenet.putExtras(bundle);
PendingIntent appIn = PendingIntent.getBroadcast(getContext(), 0, notifyIntenet, PendingIntent.FLAG_CANCEL_CURRENT);
Notification myNoti = new Notification();
myNoti.icon = IconId;
myNoti.tickerText = msg;
myNoti.defaults = Notification.DEFAULT_SOUND;
myNoti.when = System.currentTimeMillis();
myNoti.setLatestEventInfo(getContext(), title, msg, appIn);
MyNotiManager.notify(notiid, myNoti);
}
不知道我这样写是否有错,如果我传入
SendNotification("第一条",2,new Bundle()...,"标题1",100);
SendNotification("第二条",2,new Bundle()...,"标题2",200);然后当点击了第一条,执行了逻辑后,在点击"第二条"就点击了没反应了,为什么呢?

解决方案 »

  1.   

    apidemos里
         PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                    new Intent(this, NotificationDisplay.class)
                            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                            .putExtra("moodimg", moodId),
                    PendingIntent.FLAG_UPDATE_CURRENT);
    pending是这么建立的。我看apidemos是可以显示多个notification的,只不过如果有两个以上的,需要修改setLatestEventInfo,apidemos里就有这个bug,3个button是不同的通知,但是如果连续依次点三个按钮,第二次的不会显示出来。但是第一次和最后一次的能显示出来。
      

  2.   

    是不是ID的问题,每次显示,它的ID要不一样才会显示多个