ExoPlayer Notifications appear onTop of notification bar in Android 12

747 Views Asked by At

enter image description here

The Noticiation laods fine but its located ontop of my notification bar.

I'am using Android 12 on a Noxia X10

Please Help me out

Code:

        private fun createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            val serviceChannel = NotificationChannel(
                UPDATE_ALERT_ID,
                UPDATE_ALERT,
                NotificationManager.IMPORTANCE_NONE
            )
            serviceChannel.lightColor = Color.BLUE
            serviceChannel.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
            val service = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
            service.createNotificationChannel(serviceChannel)
        }
    }

This is how I Build the notifications

I have tried changing the Importance of the notification but it its not where the issue is from.

Code:

      val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
        createChannel(notificationManager)
        playerNotificationBuild = PlayerNotificationManager.Builder(this, NOTIFICATION_ID, CHANNEL_ID,
            object : PlayerNotificationManager.MediaDescriptionAdapter {
                override fun getCurrentContentTitle(player: Player): CharSequence {
                    return activeAudio?.song_name.toString()
                }

                override fun createCurrentContentIntent(player: Player): PendingIntent? {
                    val intent = Intent(applicationContext, MainActivity::class.java);
                    return PendingIntent.getActivity(
                        applicationContext, 0, intent,
                        PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
                    )
                }

                override fun getCurrentContentText(player: Player): CharSequence? {
                    return activeAudio?.song_artist
                }

                override fun getCurrentLargeIcon(
                    player: Player,
                    callback: PlayerNotificationManager.BitmapCallback
                ): Bitmap? {
                    return BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher_foreground)
                }

            }).setNotificationListener(object : PlayerNotificationManager.NotificationListener {

            override fun onNotificationCancelled(notificationId: Int, dismissedByUser: Boolean) {
                super.onNotificationCancelled(notificationId, dismissedByUser)
                removeNotification()
                stopSelf()
                stopForeground(true)
            }

            override fun onNotificationPosted(notificationId: Int, notification: Notification, ongoing: Boolean) {
                super.onNotificationPosted(notificationId, notification, ongoing)
                if (ongoing) startForeground(notificationId, notification) else stopForeground(false)
            }
        })
        playerNotificationManager = playerNotificationBuild!!.build()
        playerNotificationManager!!.setMediaSessionToken(mediaSession!!.sessionToken)
        playerNotificationManager!!.setSmallIcon(R.mipmap.ic_launcher_foreground)
      //  playerNotificationManager!!.setControlDispatcher(DefaultControlDispatcher(0, 0))
        playerNotificationManager!!.setPriority(PRIORITY_LOW)
        playerNotificationManager!!.setPlayer(mSimpleExoPlayer)
0

There are 0 best solutions below