在单个通知中显示多条消息

时间:2016-05-23 11:33:08

标签: android

如何在一个通知中获取多封邮件。这是我的以下代码段

NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(context);//

                Intent nIntent = new Intent(context, ConvActivity.class);
                PendingIntent nPendingInten = PendingIntent.getActivity(context, 0, nIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);

                nBuilder.setSmallIcon(R.drawable.app_icon_indietext_new);
                nBuilder.setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.app_icon_indietext_new));
                nBuilder.setContentTitle(senderNum);
                nBuilder.setContentText(message);
                nBuilder.setStyle(new NotificationCompat.InboxStyle()
                                .addLine(message)
                                .addLine(message))
                .setGroup(GROUP_KEY_EMAILS)
                .setGroupSummary(true)
                 .build();


                TaskStackBuilder nStackBuilder = TaskStackBuilder.create(context);
                nStackBuilder.addParentStack(ConvActivity.class);

                nStackBuilder.addNextIntent(nIntent);
                nBuilder.setContentIntent(nPendingInten);

                NotificationManager nNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);


                nBuilder.setAutoCancel(true);

                //nNotificationManager.notify(0, nBuilder.build());
                nNotificationManager.notify(9999,nBuilder.build());

获取多个通知的程序是什么

1 个答案:

答案 0 :(得分:0)

您只需使用不同的ID     mNotificationManager.notify(ID,notifyDetails);

并在这些ID

中设置多条消息