如何合并多个推送通知?

时间:2014-10-11 07:33:43

标签: android

我的问题是如何合并多个通知? 这是我的代码:

    private void sendNotification(String msg) {
    mNotificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, DemoActivity.class), 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
            this)
            .setSmallIcon(R.drawable.ic_stat_gcm)
            .setContentTitle("GCM Notification")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(result))
            .setContentText(result);

    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(++NOTIFICATION_ID, mBuilder.build());
}

它为我提供了像Windows手机这样的每个通知,但我无法合并到通知中。那么,请告诉我在这种方法中要实施的内容。

1 个答案:

答案 0 :(得分:1)

您不能简单地添加多个通知。收到通知时,您只需要做一些逻辑工作。假设您正在制作聊天应用。您会收到消息通知。现在,当您收到其他消息的通知时,请检查是否有待处理的未读消息。如果是这样,请将通知文本更改为“x new messages”。