-2
我想要構建一個應用程序,該應用程序接收用戶的短語,在網絡上搜索並在結果中顯示結果(因此它會更舒適地展示)。Android - 我如何開始網絡搜索並獲得結果到我的活動
到目前爲止,我設法啓動Google搜索,但無法將結果返回到我的活動。我試過StartActivityForResults
,但似乎Google搜索不支持它。 我想以URL列表的形式或類似的東西獲得搜索結果,所以我可以在我的應用程序的另一個活動中打開它。有什麼建議麼?
這是到目前爲止我的代碼:
public void SearchWeb (View view) {
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
EditText editText = (EditText) findViewById(R.id.edit_message); //get text from EditText
String query = editText.getText().toString();
query = query.concat(" chords");
intent.putExtra(SearchManager.QUERY, query);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}