如何解决Android 通知样式
我似乎无法有效地设置通知样式。我有一个在前台服务中运行的通知,我不想创建自定义通知,因为它没有像我想要的那样优雅地呈现。我似乎无法像文档中那样创建它。 like this one
通知是一个主动呼叫通知,它需要在用户可能拥有的其他通知之间尽可能与众不同。
// styling notification
Spannable spannable = new SpannableString(input);
spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),input.length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.addLine(spannable);
inboxStyle.addLine(getNotificationContent(getApplicationContext(),type).text);
Notification notification = new NotificationCompat.Builder(this,CHANNEL_ID)
.setContentTitle(Build.VERSION.SDK_INT == 23 ? getApplicationContext().getResources().getString(R.string.app_name) : "")
// conditional Content and Icon depending on the @IncallNotificationType
.setContentText(
type == NotificationHandler.InCallNotificationType.NORMAL
? input
: getNotificationContent(getApplicationContext(),type).text)
.setSmallIcon(
type == NotificationHandler.InCallNotificationType.NORMAL
? android.R.drawable.ic_menu_call
: getNotificationContent(getApplicationContext(),type).resId)
.setGroup("false")
.setPriority(Notification.PRIORITY_MAX)
.setFullScreenIntent(fullScreenPendingIntent,true)
.setColorized(true)
.setUsesChronometer(true).setWhen(timeStarted)
.setStyle(inboxStyle)
.setColor(ContextCompat.getColor(getApplicationContext(),R.color.accent))
.addAction(R.drawable.ic_general_loud,"speaker",speakerPendingIntent)
.addAction(R.drawable.selector_mute,muteButtonText,mutePendingIntent)
.addAction(R.drawable.ic_general_hold,"end call",endCallPendingIntent)
.build();
这是我的通知 here
我想要做的是减少从 AppName 到“正在调用”的间距,如果可能,更改按钮的背景。 所以,我想设置此通知的样式,但不能使用自定义通知。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。