Android:クイック検索ボックスの結果インターネットを収集します
-
09-10-2019 - |
質問
ユーザーがサーバーで検索できるアプリを行っています。クイック検索ボックスからテキストを取得してサーバーに送信するにはどうすればよいですか?
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String search= intent.getStringExtra(SearchManager.QUERY);
}
文字列「検索」は、ユーザーが入力するテキストですか?
P/S:私の悪い英語について申し訳ありません。皆さんが私が話していることを理解してください。ありがとう。
由来
Wynix
解決
はい、文字列「検索」は、ユーザーが検索した文字列です。
これができたら、HTTPGET-Objectを使用してサーバーにリクエストを送信できます。
HttpGet get = new HttpGet("http://yourserver.com" + search);
HttpResponse response = null;
try {
response = client.execute(get);
}
catch (IOException e) {}
catch (ClientProtocolException e) {}
次に、httpresponse-objectの結果を解析できます。
String result = EntityUtils.toString(response.getEntity());
所属していません StackOverflow