简体   繁体   English

Android状态栏通知

[英]Android Status bar notification

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

Here it's saving the last notification in status bar if there are mutiple notifications at the same time. 如果同时有多个通知,则它将最后一条通知保存在状态栏中。 Is there any way that it will save mutiple notifications on status bar ? 有什么方法可以将多个通知保存在状态栏上?

your answer is here : 您的答案在这里

If the PendingIntent has the same operation, action, data, categories, components, and flags it will be replaced. 如果PendingIntent具有相同的操作,操作,数据,类别,组件和标志,则它将被替换。

Depending on the situation i usually solve this by providing a unique request code either as static values (0,1,2) or the row id of the data I'm receiving from the DB. 根据情况,我通常通过提供唯一的请求代码(例如静态值(0,1,2)或我从DB接收的数据的行ID)来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM