Timeout in DefaultHttpClient Class Android
<p>I have created an Android application where I connect to a remote server php file to retrieve some information. Below is the code for that. </p>

<p>Here I want to add timeout with the connection such as the connection will timeout in 5 seconds. </p>

<p>Any idea how to do this.</p>

<pre><code>ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
nameValuePairs.add(new BasicNameValuePair("name","test"));

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://mysite.com/test.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost); 
</code></pre>

<p>Regards,</p>

<p>Shankar</p>
