android 通知多行,Android多行通知,例如Gmail应用

我正在尝试创建一个多行通知,如Gmail应用程序所示,如下图所示(5个通知分组在一个通知下)

我尝试了各种示例,但似乎只能创建单个通知

public void createSingleNotification(String title, String messageText, String tickerttext) {

int icon = R.drawable.notification_icon; // icon from resources

CharSequence tickerText = tickerttext; // ticker-text

long when = System.currentTimeMillis(); // notification time

Context context = getApplicationContext(); // application Context

CharSequence contentTitle = title; // expanded message title

CharSequence contentText = messageText; // expanded message text

Intent notificationIntent = new Intent(this, MainActivity.class);

Bundle xtra = new Bundle();

xtra.putString("title", title);

xtra.putString("message", messageText);

notificationIntent.putExtras(xtra);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0,

notificationIntent, PendingIntent.FLAG_ONE_SHOT

+ PendingIntent.FLAG_UPDATE_CURRENT);

String ns = Context.NOTIFICATION_SERVICE;

NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

Notification notification = new Notification(icon, tickerText, when);

notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

notification.defaults |= Notification.DEFAULT_LIGHTS;

notification.defaults |= Notification.DEFAULT_SOUND;

notification.defaults |= Notification.FLAG_AUTO_CANCEL;

notification.flags = Notification.DEFAULT_LIGHTS

| Notification.FLAG_AUTO_CANCEL;

final int HELLO_ID = 0;

mNotificationManager.notify(HELLO_ID, notification);

}

我不知道如何创建一个我可以添加行的通知组.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值