2011-10-04 138 views
1
private void triggerNotification(String s)  
{   
    CharSequence title = "TASK";   
    CharSequence message = s;  

    notificationManager = (NotificationManager)c.getSystemService(Context.NOTIFICATION_SERVICE);   
    Notification notification = new Notification(R.drawable.vianetlogo, s, System.currentTimeMillis()); 

    notification.defaults |= Notification.DEFAULT_SOUND; 
    notification.defaults |= Notification.DEFAULT_VIBRATE; 

    PendingIntent pendingIntent = PendingIntent.getActivity(c, 0, null, 0); 

    notification.setLatestEventInfo(c, title, message, pendingIntent); 
    notificationManager.notify(NOTIFICATION_ID, notification);  
} 

如果同时存在多个通知,则会在状态栏中保存上次通知。有没有什么办法,这将节省状态栏多发的通知?Android状态栏通知

回答

0

你的答案是here

如果具有的PendingIntent相同的操作,动作,数据,类别,组件和标志也将被替换。

根据情况我通常通过提供一个唯一的请求代码来解决这个问题,无论是静态值(0,1,2)还是我从数据库接收的数据的行ID。

+0

它的工作!!!!!!!!!!!! – user533844

+0

@ user533844好工作;) –