如何在Android中将文本从Activity传递到Google Now搜索

buk*_*.wh 2 java android google-now

我有一个EditText和Button的活动.当用户按下按钮时,我需要从我的活动中启动Google即时搜索,并从EditText传递文本以使Google即时搜索此文本.我怎样才能做到这一点?

Udi*_*jee 6

试试这个

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);
Run Code Online (Sandbox Code Playgroud)

你可以在这里获得更多信息