简体   繁体   English

在Android Wear通知中使用来自网址的图片

[英]Use a image from url in a android wear notification

I´m using notifications for the androidwear watch in my project. 我正在项目中为androidwear手表使用通知。 My intentention is that the background of the notificatión will be an image extract from a url, but i don´t know how to do it. 我的意图是,通知的背景将是从URL中提取的图像,但是我不知道该怎么做。

The doc of the NotificationCompat.WearableExtender()explain: NotificationCompat.WearableExtender()的文档说明:

.setBackground(bBitmap);

but.. if i want to load the backgroud from a url? 但是..如果我想从URL加载背景?

i´ll be reading about this, but without success. 我将阅读有关此内容,但没有成功。

Thanks in advance. 提前致谢。

Use Volley (Highly efficient networking library) to download the image in URL and use it. 使用Volley(高效网络库)下载URL中的图像并使用它。 You will get a bitmap response. 您将得到一个位图响应。 There are various tutorials for Volley ImageRequest. Volley ImageRequest有各种教程。

See this question Import Android volley to Android Studio to see how to add volley library to android-studio 查看此问题将Android Volley导入Android Studio,以了解如何将Volley库添加到android-studio

Try this to learn to requst images from url using volley. 尝试此操作以学习使用凌空从url请求图像。

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

if u still cant't do it, i can help u with the code. 如果您仍然不能执行此操作,那么我可以为您提供代码。 Happy coding :) 快乐的编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM