Android : collect Quick Search Box result form internet
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());
精彩评论