How do I download images from google in my android app?

时间:2015-09-01 22:10:51

标签: android json xml-parsing google-search-api android-search

I am building a music player app and I want to do the following things:

  1. Query artist and album art images from google
  2. Download the first image in google results.
  3. Resize it (I dont want the full image if its too big).
  4. Save it in a local disk cache so that it doesn't disappear when the device is offline or I don't have to download it every time.

I have searched the web and got to know about google web search API. But I could make little sense of it. Most of the examples are about implementing a search engine, however that's not what I want. I am not familiar with XML parsing or JSON. Can someone cite my tutorials or give a rough idea of how things work or how do I nake it work.

Please help.

1 个答案:

答案 0 :(得分:1)

You can use the Google Volley library. It will do all those things for you

Volley Tutorial All the info is in the Tutorial to get you going and adjust to your project

except

Resize it (I dont want the full image if its too big)

Once volley NetworkImage has downloaded the image you grab the raw data from the Cache and using Bitmap you can scale it and Cache it again. You can also discard the old image from the cache if you dont want it but you need to read the Volleys Documentation from Google to understand all the features it has.

相关问题