NotificationCompat.MediaStyle: Easier Media Notifications for all
Remember back in October 2014 when we talked about MediaStyle notifications ? With no lock screen controls for media playback on Android 5.0+ devices, Android introduced a new 'style' of notification in MediaStyle - designed to make it easy to add playback controls to your notification in both their compact state and expanded state. In AppCompat 22.2.0, we've backported MediaStyle through NotificationCompat
:On API 14-19 devices
We override the compact content view, updating the styling to match that found on Android 5.0+ and displaying any actions (up to 3) set in setShowActionsInCompactView()
 inline with the notification, even when it is compact and only a single line.On API 16-19 devices
In addition to providing the customized content view, we take advantage of Android 4.1's expanded notifications to also provide a customized big content view that matches that found on Android 5.0+ devices, showing up to 5 actions in the notification.On API 21+ devices
On Android 5.0+ devices, we use the frameworks's MediaStyle directly, ensuring everything works exactly as expected.
If you're already using MediaSessionCompat
 (which you totally should - backward compatible MediaSession that automatically takes care of RemoteControlClient for you!), you'll note that setMediaSession()
 takes a MediaSessionCompat.Token, ensuring that the system picks up your notification as associated to a MediaSession on Android 5.0+ devices (needed for things like Android Wear and Auto integration) without any version checking required.
We've also taken special care to work around issues with ongoing notifications, common with media applications - you'll note the setShowCancelButton()
 method allows you to add a cancel button (a little 'X' in the upper right) on pre-5.0 devices so that users can remove your notification, even if set as an ongoing notification. Read more details in the Javadoc of the method.
I hope this makes it a lot easier to build great media apps that work well on all Android versions. Between MediaSessionCompat and NotificationCompat.MediaStyle, you'll find it much easier to build the best Android integration into your app!
 - https://plus.google.com/+AndroidDevelopers/posts/81YUVaLAnd2
 - https://developer.android.com/reference/android/support/v7/app/NotificationCompat.MediaStyle.html#setShowActionsInCompactView(int..
 - https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.html
 - https://developer.android.com/reference/android/support/v7/app/NotificationCompat.MediaStyle.html#setMediaSession(android.support.v4.media.session.MediaSessionCompat.Token)
 - https://developer.android.com/reference/android/support/v7/app/NotificationCompat.MediaStyle.html#setShowCancelButton(boolean)