How can I implement idle timeout in android?

how to implement request timeout in android?

  • friends, I'm running into an issue when i try to call webservice and the server/internet is not available. It appears that the connection is taking a long time to timeout can i set timout manually to show error messgage to user? any help would be appreciated.

  • Answer:

    Set up your HttpClient this way. BasicHttpParams httpParams = new BasicHttpParams(); ConnManagerParams.setTimeout(httpParams, connectionTimeoutInMs); httpClient = new DefaultHttpClient(httpParams);

UMAR at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

You can try to do it this way: URL url; URLConnection connection; try { url = new URL("http://foo.bar.com"); connection = url.openConnection(); connection.setConnectTimeout(3000); // set 3 seconds for timeout connection.connect(); }catch(SocketTimeoutException ss){ // show message to the user }

Cristian

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.