Am building an music player app. I want to implement media controller in notification bar. I have tried one method http://www.binpress.com/tutorial/using-android-media-style-notifications-with-media-session-controls/165. But it only supports lollipop version of android. Does anyone have idea to build media controller in notification bar ?
Asked
Active
Viewed 2,683 times
0
-
1Use android support library.http://developer.android.com/tools/support-library/index.html – NovusMobile Jul 20 '15 at 04:54
-
no use :( ... Not working – Bincy Baby Jul 20 '15 at 04:59
-
1http://stackoverflow.com/questions/12526228/how-to-put-media-controller-button-on-notification-bar – NovusMobile Jul 20 '15 at 05:09
1 Answers
1
You have to use NotificationCompat with MediaStyle: https://developer.android.com/reference/android/support/v7/app/NotificationCompat.MediaStyle.html
Notification noti = new NotificationCompat.Builder()
.setSmallIcon(R.drawable.ic_stat_player)
.setContentTitle("Track title")
.setContentText("Artist - Album")
.setLargeIcon(albumArtBitmap))
.setStyle(new NotificationCompat.MediaStyle()
.setMediaSession(mySession))
.build();
A full example of implementing mediaSessionCompat with NotificationCompat can be found here: https://bitbucket.org/nonameden/android-universalmusicplayer-compat/src/412465d6605fee26f197cc5615f7da15cc859d4a/mobile/src/main/java/com/example/android/uamp/MediaNotificationManager.java?at=master

Martijn00
- 3,569
- 3
- 22
- 39
-
i checked the link you share but unable to understand the code so if it is possible so can you please share detailed code i know how to set notification but stuck in another problem like change the lock screen background and control buttons on lock screen check this https://stackoverflow.com/questions/54595575/how-to-set-this-type-of-view-for-a-notification – Vipul Chauhan Feb 11 '19 at 07:20