0

I have made a music app recently using media3 version 1.1.0. I was trying to customize the media notification by using setMediaNotificationProvider in onCreate of my MediaSessionService. This is my configuration

setMediaNotificationProvider(object : MediaNotification.Provider {
            override fun createNotification(
                mediaSession: MediaSession,
                customLayout: ImmutableList<CommandButton>,
                actionFactory: MediaNotification.ActionFactory,
                onNotificationChangedCallback: MediaNotification.Provider.Callback
            ): MediaNotification {
                val builder = NotificationCompat.Builder(this@Media3PlaybackService, "hi")
                    .setSmallIcon(R.drawable.ic_home)
                    .setContentTitle("My notification")
                    .setContentText("Hello World!")
                    .setStyle(MediaStyleNotificationHelper.MediaStyle(this@Media3PlaybackService.mediaSession!!))
                return MediaNotification(12, builder.build())
            }

            override fun handleCustomCommand(
                session: MediaSession,
                action: String,
                extras: Bundle
            ): Boolean {
                return true
            }
        })

It caused me the exception of this android.app.RemoteServiceException: Bad notification for startForeground. Any idea for this case?

0 Answers0