在Android Wear上设置背景

K20*_*0GH 4 android wear-os

我试图在Android磨损的通知上设置背景但是我得到了错误

android.support.v4.app.NotificationCompat.WearableExtender中的setBackground无法应用于(int)

我一直想弄清楚,但我很难过.

    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));
Run Code Online (Sandbox Code Playgroud)

如果有人能指出我正确的方向,那将是值得赞赏的.谢谢

MLP*_*CiM 7

从文档中可以看出,该方法需要一个位图作为输入.

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

public NotificationCompat.WearableExtender setBackground(Bitmap background)

设置要在通知内容后面显示的背景图像.与NotificationCompat.BigPictureStyle相反,此背景适用于任何通知样式.

参数

background - 背景位图

R.drawable.XXX是框架的整数标识符,用于查找物理资产.用于BitmapFactory.decodeResource(context.getResources(), R.drawable.XXX)从资产中检索位图并稍后应用.