Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting background on Android Wear

I'm trying to set a background on a notfication on Android wear however I get the error

setBackground in android.support.v4.app.NotificationCompat.WearableExtender cannot be applied to (int)

I've been trying to figure it out for a while but I'm stumped.

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle("Code Received")
            .setContentText("Your Orange Wednesday code is " + orangeCode)
            .extend(new NotificationCompat.WearableExtender().setBackground(R.drawable.orangebg));

If anyone is able to point me in the right direction, that would be appreciated. Thanks

like image 312
K20GH Avatar asked Mar 19 '23 19:03

K20GH


1 Answers

As can be seen in the documentation the method needs a bitmap as input.

https://developer.android.com/reference/android/support/v4/app/NotificationCompat.WearableExtender.html#setBackground(android.graphics.Bitmap)

public NotificationCompat.WearableExtender setBackground (Bitmap background)

Set a background image to be displayed behind the notification content. Contrary to the NotificationCompat.BigPictureStyle, this background will work with any notification style.

Parameters

background - the background bitmap

R.drawable.XXX is an integer identifier for the framework to find your physical asset. Use BitmapFactory.decodeResource(context.getResources(), R.drawable.XXX) to retrieve the bitmap from your assets and apply it later.

like image 196
MLProgrammer-CiM Avatar answered Mar 27 '23 21:03

MLProgrammer-CiM