开发者

Android : collect Quick Search Box result form internet

开发者 https://www.devze.com 2023-01-21 10:24 出处:网络
I\'m doing a app which allow user to search on the server. how can i get the text from the Quick Search Box and send to server?

I'm doing a app which allow user to search on the server. how can i get the text from the Quick Search Box and send to server?

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

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

the string "search" is it the text which typing by user?

P/S: sorry about my bad english. Hope you guys und开发者_如何学编程erstand what's I'm talking about. Thanks.

Regard

Wynix


Yes, the String "search" is the string the user has searched for.

Once you have this you can send a request to your server using an HttpGet-object:

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

Then you can parse the result from the HttpResponse-object:

String result = EntityUtils.toString(response.getEntity());
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号