-
-
Save Arunshaik2001/74eb33025884b17038640ac44f2b21ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun createNotificationWithMediaControl(context: Context){ | |
val icon = BitmapFactory.decodeResource( | |
context.resources, | |
R.drawable.aquarium | |
) | |
val mediaSession = MediaSessionCompat(context,"myTag") | |
val notification = NotificationCompat.Builder(context, NotificationChannels.CHANNEL1) | |
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) | |
.setSmallIcon(R.drawable.desk) | |
.addAction(R.drawable.previous, "Previous", null) | |
.addAction(R.drawable.pause, "Pause", null) | |
.addAction(R.drawable.next, "Next", null) | |
.setStyle(androidx.media.app.NotificationCompat.MediaStyle() | |
.setShowActionsInCompactView(0,1,2) | |
.setMediaSession(mediaSession.sessionToken)) | |
.setContentTitle("music_land") | |
.setContentText("Creative Awesome Band") | |
.setLargeIcon(icon) | |
.build() | |
with(NotificationManagerCompat.from(context)) { | |
notify(12544567, notification) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment