Android 如何使用默认浏览器在google上搜索字符串

Android 如何使用默认浏览器在google上搜索字符串,android,android-intent,google-api,android-searchmanager,Android,Android Intent,Google Api,Android Searchmanager,我想实现一个搜索功能,打开默认浏览器并搜索传递的字符串 public void searchOnGoogle(String keywords){ --- } 有没有办法使用意图过滤器,或者我必须自己实现一切 String query = URLEncoder.encode(keywords, "utf-8"); String url = "http://www.google.com/search?q=" + query; Intent intent = new Intent(Intent.AC

我想实现一个搜索功能,打开默认浏览器并搜索传递的字符串

public void searchOnGoogle(String keywords){
---
}
有没有办法使用意图过滤器,或者我必须自己实现一切

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