我正在尝试为 Android Wear 上的通知设置背景,但出现错误
setBackground in android.support.v4.app.NotificationCompat.WearableExtender cannot be applied to (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));
如果有人能够指出我正确的方向,那将不胜感激。 谢谢
最佳答案
如文档中所示,该方法需要位图作为输入。
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 是框架用于查找您的实物 Assets 的整数标识符。使用 BitmapFactory.decodeResource(context.getResources(), R.drawable.XXX)
从您的 Assets 中检索位图并稍后应用。
关于android - 在 Android Wear 上设置背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25188364/