title: How to check Internet connectivity Timeout for apache client in android
body: <p><strong>I have a Android Client Code (Here i am checking the timeout for internetconnection-doInBackground)</strong>::</p>
  
  <pre><code>public static void isNetworkAvailable(Context context){
      HttpGet httpGet = new HttpGet("http://www.google.com");
      HttpParams httpParameters = new BasicHttpParams();
      // Set the timeout in milliseconds until a connection is established.
      // The default value is zero, that means the timeout is not used.
      int timeoutConnection = 3000;
      HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
      // Set the default socket timeout (SO_TIMEOUT)
      // in milliseconds which is the timeout for waiting for data.
      int timeoutSocket = 5000;
      HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
  
      DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
      try{
          Log.d(TAG, "Checking network connection...");
          httpClient.execute(httpGet);
          Log.d(TAG, "Connection OK");
          return;
      }
      catch(ClientProtocolException e){
          e.printStackTrace();
      }
      catch(IOException e){
          e.printStackTrace();
      }
  
      Log.d(TAG, "Connection unavailable");
  }
  </code></pre>
  
  <hr>
  
  <p><strong>My Question</strong>:: How to check Timeout for my Apache Client below</p>
  
  <hr>
  
  <p><strong>My Apache Code (doInBackground)</strong>::</p>
  
  <pre><code>protected Void doInBackground(String... urls) {
          JSONObject jsonObject;  
          JSONArray jsonArrayTable;
          final HttpClient Client = new DefaultHttpClient();
          try {
              publishProgress(1);
              publishProgress(2);
              getPlaceNameFromMapQuestApi();
  
              mDbHelper = new DatabaseHandler(context);
              db = mDbHelper.getWritableDatabase();//Start the Database Transaction
              db.beginTransaction();//Start the Database Transaction
  
              HttpGet httpget = new HttpGet(URL);
              ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();
              Content = Client.execute(httpget, responseHandler);
              jsonObject = new JSONObject(Content);   
              //Get Data from from JSON ans perform Insertion
              parseTables(jsonObject);
              if(isDistanceCal==true) distanceCalculation();  
              db.setTransactionSuccessful();//Commit the Transaction
              isDownloadAsynTaskSucceed=true;//Set this flag so that i can start the next activity
          } catch (Exception e) {
              e.printStackTrace();
              if(isErr==false){
                  errMsg=e.toString();
                  isErr=true;
              }
              publishProgress(0);// This is necessary to make sure that alert is popped in opprogressupdate 
          }finally{
              db.endTransaction();//End the Database Transaction
              db.close();//close the database connection
          }
          return null;
      }
  </code></pre>