title: How to solve error "Invalid use of BasicClientConnManager : Make sure to release the connection before allocating another one" in Android?
body: <p>Here I am trying to POST some data from mobile to the server.For that First I have to login for authentication on the server. then after I am sending the data via POST request
  I have checked this related stackoverflow question. <a href="https://stackoverflow.com/questions/4775618/httpclient-4-0-1-how-to-release-connection">HttpClient 4.0.1 - how to release connection?</a></p>
  
  <p>I have tried all these methods one by one.</p>
  
  <p>1.EntityUtils.consume(entity);</p>
  
  <p>2.is.close();</p>
  
  <ol start="3">
  <li><p>response.getEntity().consumeContent();   //in that consumeContent() shows to be Deprecated </p></li>
  <li><p>post.abort(); </p></li>
  </ol>
  
  <p>Here is my detailed code in the pastebin links please check this.</p>
  
  <p>Here are the program flow. </p>
  
  <ol>
  <li><p>First login is called
  <a href="http://pastebin.com/idiNfnYD" rel="nofollow noreferrer">Check HERE MY LOGIN REQUEST</a></p></li>
  <li><p>After login and before post idea <a href="http://pastebin.com/bVsz7i50" rel="nofollow noreferrer">THIS</a> method is called.</p></li>
  <li><p>And finally <a href="http://pastebin.com/10aKhzme" rel="nofollow noreferrer">post idea</a> method is called.</p>
  
  <p>but logcat is showing me error :</p>
  
  <p><strong>java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.</strong></p>
  
  <p><strong>Make sure to release the connection before allocating another one</strong></p></li>
  </ol>
  
  <blockquote>
  <pre><code>W/System.err( 2217): java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
  W/System.err( 2217): Make sure to release the connection before allocating another one.
  W/System.err( 2217):  at ch.boye.httpclientandroidlib.impl.conn.BasicClientConnectionManager.getConnection(BasicClientConnectionManager.java:161)
  W/System.err( 2217):  at ch.boye.httpclientandroidlib.impl.conn.BasicClientConnectionManager$1.getConnection(BasicClientConnectionManager.java:138)
  W/System.err( 2217):  at ch.boye.httpclientandroidlib.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:455)
  W/System.err( 2217):  at ch.boye.httpclientandroidlib.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:902)
  W/System.err( 2217):  at ch.boye.httpclientandroidlib.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:801)
  W/System.err( 2217):  at ch.boye.httpclientandroidlib.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:780)
  W/System.err( 2217):  at com.rahul.cheerfoolz.api.util.postData(util.java:436)
  W/System.err( 2217):  at com.rahul.cheerfoolz.postidea.idea.post_myidea_edit$Post_Idea.doInBackground(post_myidea_edit.java:354)
  W/System.err( 2217):  at com.rahul.cheerfoolz.postidea.idea.post_myidea_edit$Post_Idea.doInBackground(post_myidea_edit.java:1)
  W/System.err( 2217):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
  W/System.err( 2217):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
  W/System.err( 2217):  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  W/System.err( 2217):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
  W/System.err( 2217):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
  W/System.err( 2217):  at java.lang.Thread.run(Thread.java:1019)
  </code></pre>
  </blockquote>