Start Google search query from activity - Android

后端 未结 5 1584
情书的邮戳
情书的邮戳 2020-12-14 08:42

I was wondering if there is an easier way (or any way) to start a Browser with a Google search query. For example user can select a certain word or phrase and click a button

5条回答
  •  感情败类
    2020-12-14 09:17

    The Intent class defines an action specifically for web searches:

    http://developer.android.com/reference/android/content/Intent.html#ACTION_WEB_SEARCH

    Here's an example of how to use it:

    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, query); // query contains search string
    startActivity(intent);
    

提交回复
热议问题