How to pass text from Activity to Google Now search in Android

柔情痞子 提交于 2019-12-11 03:13:34

问题


I have an activity with EditText and Button. When user is pressing the button i need to launch Google Now Search from my Activity and pass a text from EditText to make Google Now search for this text. How can i do this?


回答1:


Try this

String query = editText.getText().toString();
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra("query", query);
startActivity(intent);

you can get more info here



来源:https://stackoverflow.com/questions/31156147/how-to-pass-text-from-activity-to-google-now-search-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!