Я пытаюсь установить цвет фона (белый) для своего пользовательского представления уведомлений, но на android уведомление X приходит с черным фоном. Ниже мой код для генерации уведомления:
context?.let {
val notificationLayout = RemoteViews(it.packageName, R.layout.custom_notification_collapsed)
val notificationLayoutExpanded = RemoteViews(it.packageName, R.layout.custom_notification)
notificationLayout.setImageViewResource(R.id.iv_icon, R.drawable.custom_notification_icon)
notificationLayout.setTextViewText(R.id.tv_app_name, it.getString(R.string.app_name))
notificationLayout.setTextViewText(R.id.time_stamp, it.getString(R.string.just_now))
notificationLayoutExpanded.setImageViewResource(R.id.iv_icon, R.drawable.custom_notification_icon)
notificationLayoutExpanded.setTextViewText(R.id.tv_app_name, it.getString(R.string.app_name))
notificationLayoutExpanded.setTextViewText(R.id.tv_popup_content, it.getString(R.string.class_meeting_for_class_name_is_beginning_please_check_in_if_you_are_present))
notificationLayout.setTextViewText(R.id.time_stamp, it.getString(R.string.just_now))
// Create an explicit intent for an Activity in your app
val intent = Intent(it, SplashActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
val pendingIntent: PendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
val fullScreenPendingIntent = PendingIntent.getActivity(context, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT)
var builder = NotificationCompat.Builder(it, AppConstants.CHANNEL_ID)
.setSmallIcon(R.drawable.custom_notification_icon)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContent(notificationLayoutExpanded)
.setAutoCancel(true)
.setColor(resources.getColor(R.color.mdtp_white))
.setFullScreenIntent(fullScreenPendingIntent, true)
.setCustomContentView(notificationLayoutExpanded)
.setCustomBigContentView(notificationLayoutExpanded)
var customNotificationCompat: NotificationManagerCompat = NotificationManagerCompat.from(it)
customNotificationCompat.notify(0, builder.build())
}