Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search a string on google using default browser

I want to implement a search function that open the default browser and search the passed string

public void searchOnGoogle(String keywords){
---
}

Is there a way using intent filter or I must implement everything by myself?

like image 248
AndreaF Avatar asked Dec 13 '12 05:12

AndreaF


1 Answers

String query = URLEncoder.encode(keywords, "utf-8");
String url = "http://www.google.com/search?q=" + query;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
like image 63
Rajesh Avatar answered Sep 21 '22 00:09

Rajesh