我想在我的Android应用中实现丰富多彩的自定义通知。
我试图实现颜色,但目前我只能设置背景颜色。我想达到这样的结果:
展开后,我的应用图片显示为通知图片。
此处我的代码:
return builder.setContentTitle("APP TITLE")
.setContentText("Some texts")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent)
.setOngoing(true)
.setAutoCancel(true)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setPriority(Notification.PRIORITY_HIGH)
.setCategory(Notification.CATEGORY_ALARM)
.setOnlyAlertOnce(false)
.setColor(getResources().getColor(R.color.colorPrimary));
如何在上面发布的环聊示例中实现彩色图标通知?
答案 0 :(得分:1)
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(messs)
.setLargeIcon(bitmap)
.setSmallIcon(R.mipmap.hangouts_launcher)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
mNotifyBuilder.setContentIntent(pIntent);
// Set Vibrate, Sound and Light
int defaults = 0;
defaults = defaults | Notification.DEFAULT_LIGHTS;
defaults = defaults | Notification.DEFAULT_VIBRATE;
defaults = defaults | Notification.DEFAULT_SOUND;
mNotifyBuilder.setDefaults(defaults);
// Set the content for Notification
mNotifyBuilder.setContentText(messs);
mNotificationManager.notify(m, mNotifyBuilder.build());