0

我正在开发与通知相关的事情。问题是click on button。我编写了以下通知相关代码:

    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.icon,
            "New update received", when);

    Intent notificationIntent = new Intent(context,
            MessageReceivedActivity.class);     

    // set intent so it does not start a new activity
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);  
    Bundle bundle=new Bundle();
    bundle.putString("post_title", message);
    notificationIntent.putExtras(bundle);   

    PendingIntent intent = PendingIntent.getActivity(context, 0,
            notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    notification.setLatestEventInfo(context, "Agility Logistics", "New update received", intent);
    //      notification.number +=1;
    // Hide the notification after its selected
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;
    notification.defaults |= Notification.DEFAULT_LIGHTS;

    notificationManager.notify(0, notification);

如果单击按钮,则该按钮onclick notification将覆盖所有其他通知。这是不可取的。那么如何在不被按钮单击通知覆盖的情况下显示所有收到的通知?

4

0 回答 0