android - How to set Timeout
In My application i am calling the web service method 开发者_开发百科but it takes more time for the response.
Because of without time specifying, i got the following Exception. How to handle it. java.net.socketException: connection Reset.
So i want to implement the timeout for that particular web service method. It means suppose web service response not get after the specified time then it will generate timeout exception. how to implement it.
can anybody help me?
thanks
URL URLObj = null;
HttpURLConnection ConnObj = null;
URLObj = new URL("Http://Url.to.the/webservice");
ConnObj = (HttpURLConnection) URLObj .openConnection();
ConnObj .setConnectTimeout(5000); // This will set the desired time out for the connection request
精彩评论