How to set time out in android Is there any way to set time out in android, if there is no response from server for specific period.

Following is code that i used for time out
   uri = new URI(url);
HttpGet method = new HttpGet(uri);
method.addHeader("Content-Type", "application/json");
HttpParams httpParameters = new BasicHttpParams();
int timeoutConnection = 60000;
HttpConnectionParams.setConnectionTimeout(httpParameters,
timeoutConnection);
int timeoutSocket = 65000;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpResponse response = httpClient.execute(method);
HttpEntity responseEntity = response.getEntity();
statuscode = response.getStatusLine().getStatusCode();

Put this in a try catch block and if exceeds the time it will throw the exception 

Try checking the coonectivity to the url first before seeking data reply