1

私はユーザーがサーバー上で検索できるようにするアプリをやっています。クイック検索ボックスからテキストを取得してサーバーに送信するにはどうすればよいですか?

if (Intent.ACTION_SEARCH.equals(intent.getAction())) {

     String search= intent.getStringExtra(SearchManager.QUERY);
}

文字列「検索」は、ユーザーが入力するテキストですか?

P / S:私の悪い英語について申し訳ありません。皆さんが私が話していることを理解してくれることを願っています。ありがとう。

由来

Wynix

4

1 に答える 1

1

はい、文字列「検索」は、ユーザーが検索した文字列です。

これを取得したら、HttpGet オブジェクトを使用してサーバーにリクエストを送信できます。

HttpGet get = new HttpGet("http://yourserver.com" + search);
HttpResponse response = null;
try {
  response = client.execute(get);
}
catch (IOException e) {}
catch (ClientProtocolException e) {}

次に、HttpResponse オブジェクトからの結果を解析できます。

String result = EntityUtils.toString(response.getEntity());
于 2010-11-24T08:38:33.360 に答える