Получение темного (черного) уведомления в соответствии с изображением, показанным здесь, когда я изменил режим отображения на Темный в Android 10. Я пытался изменить цвет текста, но он не отражается. Я использую Remote view для создания пользовательских уведомлений. Как изменить цвета текста при удаленном просмотре контента для темного и светлого режимов? Вот мой код:
val contentViewBig = RemoteViews(context.applicationContext.packageName, R.layout.design_custom_notification)
contentViewBig.setTextViewText(R.id.tvNotificationTitle, notificationTitle)
contentViewBig.setTextViewText(R.id.tvNotificationBody, notificationBody)
val nId = Random().nextInt()
val pendingIntent = PendingIntent.getActivity(context,
nId /* Request code */, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val channelId = context.getString(R.string.default_notification_channel_id)
val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationBuilder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_notification)
.setAutoCancel(true)
.setCustomContentView(contentViewBig)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setLights(Color.WHITE, 2000, 3000)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
// Since android Oreo notification channel is needed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelId,
context.resources.getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH)
channel.description = context.resources.getString(R.string.app_name)
channel.setShowBadge(true)
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
notificationManager?.createNotificationChannel(channel)
}
if (notificationManager != null) {
notificationManager.notify(nId, notificationBuilder.build())
wakeLockScreen(context)
}
