Reputation: 5859
For some reason I can't make this simple concept work on Android wear. I want the notification on Wear to have a solid color background with color of my choosing. This is what I'm trying to do:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder
.setContentTitle("title")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Text")
.setColor(Color.YELLOW);
Notification notification = builder.build();
notificationManager.notify(123456, notification);
As you can see, I'm setting the notification color to yellow. And this does set the background on the notification to yellow on the phone. But for some reason, background color on the notification I see on Android Wear is green. Please see attached screenshots.
I tried extending notification builder with a WearableExtender, but it doesn't have a "setColor"-like method, only "setBackground". Why does Wear ignore specified notification color? And where does it take that green background color from? How do I override that color?
Upvotes: 5
Views: 1406
Reputation: 679
Green background from your icon color.
You can call WearableExtender setBackground method
int notificationId = 001;
Bitmap bitmap = Bitmap.createBitmap(320,320, Bitmap.Config.ARGB_8888);
bitmap.eraseColor(Color.YELLOW);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("title")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Text")
.extend(new NotificationCompat.WearableExtender().setBackground(bitmap));
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
notificationManagerCompat.notify(notificationId , builder.build());
Upvotes: 10