AndreaF
AndreaF

Reputation: 12395

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?

Upvotes: 9

Views: 2095

Answers (1)

Rajesh
Rajesh

Reputation: 15774

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);

Upvotes: 8

Related Questions