android 通知多行,Android多图片样式通知与多行摘要文本

我正在尝试创建大图片通知,其中多个行摘要文本标记为红色,如下图所示

56gkd.jpg

我已经创建了大图片通知,但是我的摘要文本不是多行的,而是单行并且从最后剪切.如果有人知道,请指导.

NotificationManager notificationManager = (NotificationManager)

context.getSystemService(Context.NOTIFICATION_SERVICE);

String title = context.getString(R.string.app_name);

Bitmap remotePicture = null;

Bitmap appIcon = null;

// Create the style object with BigPictureStyle subclass.

NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();

notiStyle.setBigContentTitle(title);

notiStyle.setSummaryText(message);

try {

appIcon = BitmapFactory.decodeResource(context.getResources(), icon);

remotePicture = BitmapFactory.decodeStream((InputStream) new URL(image).getContent());

} catch (IOException e) {

e.printStackTrace();

}

// Add the big picture to the style.

if(remotePicture != null)

notiStyle.bigPicture(remotePicture);

// This ensures that the back button follows the recommended convention for the back key.

TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);

// Adds the back stack for the Intent (but not the Intent itself).

try {

if(in.getData() == null)

stackBuilder.addParentStack(Class.forName(in.getComponent().getClassName()));

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

// Adds the Intent that starts the Activity to the top of the stack.

stackBuilder.addNextIntent(in);

PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

Notification noti = new NotificationCompat.Builder(context)

.setSmallIcon(icon)

.setAutoCancel(true)

.setLargeIcon(appIcon)

.setContentIntent(resultPendingIntent)

.setContentTitle(title)

.setContentText(message)

.setStyle(remotePicture == null ? null : notiStyle).build();

noti.defaults |= Notification.DEFAULT_LIGHTS;

noti.defaults |= Notification.DEFAULT_VIBRATE;

noti.defaults |= Notification.DEFAULT_SOUND;

noti.flags |= Notification.FLAG_ONLY_ALERT_ONCE;

notificationManager.notify(0, noti);

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值