I use the following code to get data from a server with an http request.
HttpClient client = new DefaultHttpClient(); String URL = urlGenerator(); StringBuilder url = new StringBuilder(URL); HttpGet get = new HttpGet(url.toString()); HttpResponse response = client.execute(get); int status = response.getStatusLine().getStatusCode(); if(status == 200){ ... }
Its performance. But if the phone is connected to Wi-Fi or gprs 3g, but the Internet does not work or the Internet connection does not exist, I want to use the timeout function in the above code.
let's say after 3 seconds I want to show a timeout, try again .. how to do it. in case of timeout I want to show the text in the timeout of the textviw connection .. how do I do this please help
source share