android-避免在应用程序处于前台时通知弹出窗口
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了android-避免在应用程序处于前台时通知弹出窗口,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1579字,纯文字阅读大概需要3分钟。
内容图文
![android-避免在应用程序处于前台时通知弹出窗口](/upload/InfoBanner/zyjiaocheng/686/95e161a59ede40b8b1cacd25e9bd0f6f.jpg)
从https://material.io/guidelines/patterns/notifications.html#notifications-behavior开始,我确实能够通知用户,而无需显示通知通知.
我想在状态栏中显示一个闪烁的“喜欢”图标,而不会弹出通知提示. (如果您观看“来自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());
我想知道,当我的应用程序处于前台时,如何避免出现通知弹出窗口,而仅在状态栏中显示闪烁的图标.
解决方法:
.setPriority(NotificationManager.IMPORTANCE_LOW)
内容总结
以上是互联网集市为您收集整理的android-避免在应用程序处于前台时通知弹出窗口全部内容,希望文章能够帮你解决android-避免在应用程序处于前台时通知弹出窗口所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。