Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Android中将文本从Activity传递到Google Now搜索_Java_Android_Google Now - Fatal编程技术网

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

Java 如何在Android中将文本从Activity传递到Google Now搜索,java,android,google-now,Java,Android,Google Now,我有一个带有编辑文本和按钮的活动。当用户按下按钮时,我需要从我的活动中启动Google Now Search,并从EditText中传递文本,以使Google Now搜索此文本。我该怎么做呢?试试这个 String query = editText.getText().toString(); Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.setClassName("com.google.android.googlequi

我有一个带有编辑文本和按钮的活动。当用户按下按钮时,我需要从我的活动中启动Google Now Search,并从EditText中传递文本,以使Google Now搜索此文本。我该怎么做呢?

试试这个

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);

您可以获得更多信息

使用他们的API并在应用程序中调用,酷!这正是我需要的!非常感谢你!