Pergunta

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 understand what's I'm talking about. Thanks.

Regard

Wynix

Foi útil?

Solução

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());
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top