Start Google search query from activity - Android

后端 未结 5 1593
情书的邮戳
情书的邮戳 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:07

    I recently tried this. This appears to work fine. If any modifications to be done let me know as I am new to android development.

    mEdit   = (EditText)findViewById(R.id.editText);
    

    in your click view,

    String q = mEdit.getText().toString();
                            Intent intent = new Intent(Intent.ACTION_WEB_SEARCH );
                            intent.putExtra(SearchManager.QUERY, q);
                            startActivity(intent);
    

提交回复
热议问题