【问题标题】:Android Status bar notificationAndroid 状态栏通知
【发布时间】:2011-10-04 21:23:16
【问题描述】:
 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


    【解决方案1】:

    你的答案是here

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-15
      • 2016-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多