在 android 磨损通知中使用来自 url 的图像

Use a image from url in a android wear notification

我在我的项目中使用 androidwear 手表的通知。 我的意图是通知的背景将是从 url 中提取的图像,但我不知道该怎么做。

NotificationCompat.WearableExtender() 的文档说明:

.setBackground(bBitmap);

但是..如果我想从 url?

加载背景

我会读到这个,但没有成功。

提前致谢。

使用Volley(高效网络库)下载URL中的图片并使用。你会得到一个位图响应。 Volley ImageRequest 有各种教程。

查看此问题Import Android volley to Android Studio了解如何将 volley 库添加到 android-studio

试试这个来学习使用 volley 从 url 请求图像。

https://developer.android.com/training/volley/request.html

如果还是不行,我可以帮你写代码。 编码愉快:)