0

我正在制作一个 android 应用程序,当按下快速搜索的 go 按钮时需要打开 webbrowser。我怎样才能做到这一点?它启动网络浏览器?这是我到目前为止得到的代码:

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???
    }
}
}
4

1 回答 1

0

For how to do the search activity you have all the info here: http://developer.android.com/guide/topics/search/search-dialog.html

Starting the browser:

Intent i = new Intent(Intent.ACTION_VIEW, 
       Uri.parse("http://www.google.ro/search?q=" + searchKeywords.replace(' ', '+')));
startActivity(i);

Hope it helps.

于 2012-02-08T20:58:25.830 回答