Java 如何在我的应用程序内进行谷歌搜索并在应用程序内显示结果?
我想在Google上搜索一个字符串,并将结果显示在我活动的另一个页面中 我现在搜索的代码是:Java 如何在我的应用程序内进行谷歌搜索并在应用程序内显示结果?,java,android,xml,android-studio,google-search,Java,Android,Xml,Android Studio,Google Search,我想在Google上搜索一个字符串,并将结果显示在我活动的另一个页面中 我现在搜索的代码是: Button breakfast = (Button) findViewById(R.id.breakfast); breakfast.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // Intent myInt
Button breakfast = (Button) findViewById(R.id.breakfast);
breakfast.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Intent myIntent = new Intent(view.getContext(), Main5Activity.class);
// startActivityForResult(myIntent, 0);
try {
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String term = Main2Activity.choice + " breakfast recipe using " + Main3Activity.list;
intent.putExtra(SearchManager.QUERY, term);
startActivity(intent);
} catch (Exception e) {
// TODO: handle exception
}
}
});
然而,现在它的设置是,当代码运行时,它使用外部谷歌应用程序进行搜索,然后使用该应用程序显示结果。我希望仍在我的应用程序中搜索,并在下一个活动(Main5Activity)中显示结果。正如您所看到的,Main5Activity已经设置好了,但是我对它进行了注释,因为我不知道如何实现它
这是我希望在其中显示结果的滚动视图:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
我是谷歌API的新手,所以我能做的就是在谷歌搜索中使用外部应用程序。非常感谢您的帮助。您看过吗:Morrison Chang我查过了,但我想更多的是网站。不是我想要的