Creating a Media Player Notification

This recipe is going to take a look at the new Media Player style introduced in Android 5.0 (API 21). Unlike the previous recipe, Lights, Action, and Sound Redux using Notifications, which used NotificationCompat, this recipe does not, as this style is not available in the support library.

Here's a screenshot showing how the notification will appear:

Creating a Media Player Notification

This screenshot shows an example of the Media Player Notification on a lock screen:

Creating a Media Player Notification

Getting ready

Create a new project in Android Studio and call it: MediaPlayerNotification ...

Get Android Application Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.