Android 炫彩通知图片
Android colorful notification pictures
我想在我的 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));
如何实现彩色图标通知,就像我上面发布的视频群聊示例一样?
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());
我想在我的 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));
如何实现彩色图标通知,就像我上面发布的视频群聊示例一样?
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());