문제

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

도움이 되었습니까?

해결책

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());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top