【发布时间】:2018-08-01 23:03:44
【问题描述】:
来自https://material.io/guidelines/patterns/notifications.html#notifications-behavior,我真的能够通知用户,而不显示通知窥视。
我想在状态栏中显示一个闪烁的点赞图标,而不会弹出通知。 (如果您在 From https://material.io/guidelines/patterns/notifications.html#notifications-behavior 部分下观看第一个视频,您可以看到状态栏中的闪烁)
状态栏中的闪烁图标
但是,我不完全确定如何实现这一目标。每当我通知用户时,都会有一个通知弹出窗口。
通知弹出查看
我的代码如下
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context.getApplicationContext(), org.yccheok.notification.Utils.createNotificationChannel())
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(contentTitle)
.setTicker(ticker)
.setColorized(true)
.setColor(context.getResources().getColor(R.color.accent_material_light))
.setContentText(contentText);
mBuilder.setSound(Uri.parse(getStockAlertSound()));
mBuilder.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
mBuilder.setAutoCancel(true);
// Need BIG view?
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
// Sets a title for the Inbox style big view
inboxStyle.setBigContentTitle(contentTitle);
inboxStyle.setSummaryText(summaryText);
for (SpannableString notificationMessage : notificationMessages) {
inboxStyle.addLine(notificationMessage);
}
mBuilder.setStyle(inboxStyle);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
我想知道,当我的应用程序处于前台时,如何避免通知弹出窗口,而只在状态栏中显示一个闪烁的图标。
【问题讨论】:
标签: android