Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display clear background image on Android Wear notification?

Tags:

wear-os

As far as I can work out, there are two ways to set the background image for a notification in Android Wear. For the record, both start with:

   Bitmap bitmap;
   Notification.Builder bob = new Notification.Builder(this)
            .setContentTitle(title)

...and so on to set up the notification. Also assume that bitmap has been initialized to an appropriately-sized image (though that's another issue).

Method 1:

   bob.setLargeIcon(bitmap);

This works, but AFAICT bitmap is always blurred-out in the background of the notification, regardless of its size.

Method 2:

   bob.setStyle(new Notification.BigPictureStyle().bigPicture(bitmap));

This clears up the bitmap, but has the unfortunate side effect of inserting an extra "page" on the wearable, a page that is blank except for the bitmap. I suppose the thinking here is that you're trying to show the image to the user - but I'm not, I just want a non-blurry background.

Is there a way to accomplish this?

like image 366
Sterling Avatar asked Jul 19 '14 14:07

Sterling


1 Answers

Please use setBackground(Bitmap) method from WearableExtender instead of setLargeIcon(Bitmap). It will set the background bitmap that won't be blurred.

Notification.Builder wearableBuilder = new Notification.Builder(context)
    ...
    .extend(new WearableExtender().setBackground(bitmap));
like image 189
Maciej Ciemięga Avatar answered Oct 20 '22 04:10

Maciej Ciemięga