Вопрос

I need to get the first image url from Google images, based on given keywords, and then display it using image loader on the phone. Can anyone tell me is this possible and how can I do this?

Это было полезно?

Решение

You could use Google's Custom Search API, although that will cost you money per search.

You can also do something like this:

  • Make an Http request to this address https://www.google.com/search?tbm=isch&q=kitten
  • Write a regular expression to grab the first image's url
  • Make another Http request to that url
  • Read the result of the request into a byte array
  • Convert the byte array to a Bitmap
  • Set up an ImageView and call imgView.setImageBitmap

I'm being vague because I don't know what you've tried so far, and the actual code for this would be fairly involved.

edit: A quick search shows this relevant SO question: Google image search by image in android

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top