我正在制作一个android应用程序,当按下快速搜索的按钮时,它需要打开网络浏览器。我怎样才能做到这一点?它启动了网络浏览器?这是我目前得到的代码:
public class SearchFunction extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Intent queryIntent = getIntent();
final String queryAction = queryIntent.getAction();
if (Intent.ACTION_SEARCH.equals(queryAction)) {
String searchKeywords = queryIntent.getStringExtra(SearchManager.QUERY);
//Is it here that i can start intents/webbrowser???
}
}
}
关于如何进行搜索活动,您可以在此处获得所有信息:http://developer.android.com/guide/topics/search/search-dialog.html
启动浏览器:
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.ro/search?q=" + searchKeywords.replace(' ', '+')));
startActivity(i);
希望能有所帮助。