How can i add Button in MediaStyle Notification?

53 Views Asked by At
val mediaSession = MediaSessionCompat(baseContext, "my_media_session")
    mediaSession.setFlags(
        MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS
    )

    val mediaSessionConnector = MediaSessionConnector(mediaSession)
    mediaSessionConnector.setPlayer(videoPlayer)
    mediaSession.isActive = true

    return NotificationCompat.Builder(baseContext, AudioServiceViewModel.AudioServiceChannel)
        .setSmallIcon(R.drawable.noti_icon)
        .setShowWhen(false)
        .setContentTitle("title")
        .setContentText("text")
        .setLargeIcon(BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher_round) )
        .setColor(Color.parseColor(Vars.SPORKI_TINT_COLOR))
        .setColorized(true)
        .setStyle(androidx.media.app.NotificationCompat.MediaStyle().setMediaSession(mediaSession.sessionToken).setShowCancelButton(true))
        .setOngoing(true)
        .setContentIntent(setContentsIntentData())
        .build()

this is my source..

how can i add button in notification?

please help me!

i search stackoverflow and ask chat-gpt...

0

There are 0 best solutions below