Skip to content

Instantly share code, notes, and snippets.

@zeroarst
Created February 17, 2022 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroarst/f9699aa122c8e91c2493643c3b019a10 to your computer and use it in GitHub Desktop.
Save zeroarst/f9699aa122c8e91c2493643c3b019a10 to your computer and use it in GitHub Desktop.
NotificationCompat.Builder.setStyle.kt
val builder = NotificationCompat.Builder(this@PlaybackService, NOTI_CHANNEL_ID).apply {
setStyle(
androidx.media.app.NotificationCompat.MediaStyle().also {
it.setShowActionsInCompactView(1, 2, 3)
.setMediaSession(mediaSession.sessionToken)
.setShowCancelButton(true)
.setCancelButtonIntent(
MediaButtonReceiver.buildMediaButtonPendingIntent(
this@YourMusicService,
PlaybackStateCompat.ACTION_STOP
)
)
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment