title: Error in Android using SingleClientConnManager
body: <p>I'm currently trying to learn a bit about AsyncTask'ing in Android. I'm using a code fragment of some school project im working with, but I can't seem to run it properly. The error I am getting is the following:</p>
  
  <p><b>"Invalid use of SingleClientConnManager: connection still allocated.
  Make sure to release the connection before allocating another one."</b></p>
  
  <p>So basicly I do understand <i>what</i> it says, that I need to close the http-connection before I start another one. (Correct me if I'm wrong lol) So I'm wondering if someone could please help me out here as I've been stuck for several hours. </p>
  
  <p>The code I am using is the following:</p>
  
  <pre><code>protected class loader extends AsyncTask&lt;String, Void, String&gt; {
  
      @Override
      protected String doInBackground(String... params) {
          // TODO Auto-generated method stub
  
          try {
              httpclient = new DefaultHttpClient();
              httppost = new HttpPost("url_of_my_phpdocument_here.php");
              //legg til data
              nameValuePairs = new ArrayList&lt;NameValuePair&gt;(1);
  
              nameValuePairs.add(new BasicNameValuePair("username",username.getText().toString().trim()));
              nameValuePairs.add(new BasicNameValuePair("password",password.getText().toString().trim()));
              httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
              response=httpclient.execute(httppost);
  
              ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();
              final String response = httpclient.execute(httppost, responseHandler);
  
              //Toast.makeText(MainActivity.this,response, Toast.LENGTH_LONG).show();
  
              //tv.setText(""+response);
              if(response.equalsIgnoreCase("User Found"))
              {
                  startActivity(new Intent("com.example.obligatorisk.BROWSER"));
              }
          }
          catch(Exception e){
              e.printStackTrace();
          }
  
          return null;
      }
      // TODO Auto-generated method stub
  
  }
  </code></pre>
  
  <p>I did alot of research and I found solutions, but they seem to be very different and custom for those examples I found. Even tho I've been messing around with them for very long I can't seem to make any of them work. </p>
  
  <p>Thank you. :-)</p>