4

I was wondering how to start a Browser with a Google image search query "search images by text". For example user can select a certain word or phrase and click a button and the activity will start the browser with the Google image search query.

Thanks in advance.

Sama
  • 73
  • 1
  • 4

2 Answers2

9

Create URL like so:

String URLString = "https://www.google.com/search?hl=en&site=imghp&tbm=isch&source=hp&q="+TestString;

Launch it like so:

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(URLString));
startActivity(i);

Make sure your TestString is URL Safe

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
  • Note: the `tbm=isch` is what's need to switch to the Image tab. – Andre Bulatov Aug 19 '16 at 05:25
  • Note 2: For me, just the search query + `tbm` is all that was needed. Both on Android and Chrome on Mac OSX, it worked with just this `"https://www.google.com/search?site=imghp&q=" + searchQueryString` – Andre Bulatov Aug 19 '16 at 05:27
0

Just need to add tbm=isch

Example:

url: https://www.google.com/search?tbm=isch&q=findSomeImage

Dipakk Sharma
  • 976
  • 1
  • 8
  • 11