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
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:
- How to implement a relative timer in a game?Best solution by Stack Overflow
- How to deal with timeout when accessing a web service?Best solution by Stack Overflow
- How to implement app purchase in Android app?Best solution by Stack Overflow
- How to implement your own like button in Android?Best solution by Stack Overflow
- How to fix gateway timeout error?Best solution by pcsupport.about.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.