Не показывается уведомление на Xiaomi, хотя на avd все работает

Я пытаюсь сделать плеер на андроид и работаю над уведомлением для него. На виртуальном pixel2 API30 уведомление отображается введите сюда описание изображения но на смартфоне xiaomi Redmi 9C c 10 андроидом уведомление не приходит.

Код постройки уведомления:

private fun showNotification() {
    val remoteViews = RemoteViews(packageName, R.layout.notification_playing)

    if (nowPlayingTrack != null) {
        remoteViews.setTextViewText(R.id.notification_title, nowPlayingTrack!!.tName)
        remoteViews.setTextViewText(R.id.notification_description, nowPlayingTrack!!.tAuthor)
        remoteViews.setImageViewResource(R.id.notification_image, R.drawable.track)

        val pendingIntent: PendingIntent = PendingIntent.getActivity(this, 0, Intent(), PendingIntent.FLAG_IMMUTABLE)
        val notificationBuilder = NotificationCompat.Builder(this.applicationContext,
            NOTIFICATION_CHANNEL_ID)
        notificationBuilder
            .setDefaults(Notification.DEFAULT_ALL)
            .setSmallIcon(R.drawable.track_without_bg)
            .setSilent(true)
            .setContentTitle("Title")
            .setContentText("text")
            .setContentIntent(pendingIntent)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT)
            .setCustomContentView(remoteViews)

        val notificationManager =
            this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

        val notificationChannel = NotificationChannel(
            "vladik_music",
            NOTIFICATION_CHANNEL_NAME,
            NotificationManager.IMPORTANCE_DEFAULT
        )

        val notification = notificationBuilder.build()
        notification.flags = Notification.FLAG_NO_CLEAR

        notificationTarget = NotificationTarget(this, R.id.notification_image,
            remoteViews, notification, id)
        notificationManager.createNotificationChannel(notificationChannel)
        with(NotificationManagerCompat.from(this)) {
            this.notify(id, notification)
        }

        if (nowPlayingTrack!!.getPhoto() != null) {
            Glide.with(this@VladikMusicPlayService)
                .asBitmap()
                .load(nowPlayingTrack!!.getPhoto()!!.medium)
                .transform(RoundedCornersTransformation(50, 0))
                .into(notificationTarget)
        }
    }
}

Код layout (на всякий)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:id="@+id/notification_main_layout"
android:padding="5dp">


<ImageView
    android:layout_centerVertical="true"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:id="@+id/notification_image"/>

<TextView
    android:textSize="20sp"
    android:textColor="@color/black"
    android:layout_marginHorizontal="15dp"
    android:layout_marginVertical="5dp"
    android:textStyle="bold"
    android:id="@+id/notification_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toEndOf="@+id/notification_image"
    android:maxLines="1"/>

<TextView
    android:id="@+id/notification_description"
    android:textSize="15sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toEndOf="@id/notification_image"
    android:layout_below="@+id/notification_title"
    android:layout_marginHorizontal="15dp"
    android:maxLines="1" />
 </RelativeLayout>

Пытался менять id, убирал кастомную вью, но ничего не помогло. Прошу помогите


Ответы (1 шт):

Автор решения: Крест Доминика Туретта

Проблема была в том, что id у notification и у notification channel должны быть одинаковыми

т.е. замена

val notificationChannel = NotificationChannel(
        "vladik_music",
        NOTIFICATION_CHANNEL_NAME,
        NotificationManager.IMPORTANCE_DEFAULT
    )

на

val notificationChannel = NotificationChannel(
        NOTIFICATION_CHANNEL_ID,
        NOTIFICATION_CHANNEL_NAME,
        NotificationManager.IMPORTANCE_DEFAULT
    )
→ Ссылка