androidgoogle-search-apigoogle-image-search

how to start a browser with a Google image search query in android


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.


Solution

  • 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