u2gilles
u2gilles

Reputation: 7383

Android MediaStyle NotificationCompat background color

I'm testing on a Samsung S4 on Lollipop 5.1.1 (Cyanogen) and my app uses support library 23.2.1

I would like to know how to change the background color of a MediaStyle NotificationCompat.

In the builder, using

.setColor(mNotificationColor)

does not change the background.

What confuses me a little bit that the android-UniversalMusicPlayer-master example provided by Google (compiled with support library 23.2.1) uses successfully the same method to change the background color.

I know that the doc says that the argument of setColor is "int: The accent color to use" (and not the background color) but again android-UniversalMusicPlayer-master does it successfully.

Upvotes: 0

Views: 2105

Answers (2)

Hossein Shahdoost
Hossein Shahdoost

Reputation: 1742

The selected answer to this question is wrong, I wonder how it has taken 2 upvotes. The notification background in MediaStyle changes on android versions below 21 regardless, The solution which android-UniversalMusicPlayer-master has used (which is actually exoplayer's solution) is to have different media icons for android versions higher than 21.

So normally there are png files presenting media actions, but for api 21 or higher drawables would be replaced.

Upvotes: 0

u2gilles
u2gilles

Reputation: 7383

I have found the reason for this problem. I used the v4 appcompat support library instead of the v7

So replacing :

import android.support.v4.app.NotificationCompat;

by :

import android.support.v7.app.NotificationCompat;

fixed this issue.

This also was the reason of another of my issues with the media style notification.

Upvotes: 2

Related Questions