I am trying to create an activity to login via http post as discussed in https://stackoverflow.com/questions/24591165/android-http-reponse-code-error. Anyways upon testing I keep getting the following two warnings in my logcat:
07-06 11:55:16.934: W/SingleClientConnManager(1049): Invalid use of SingleClientConnManager: connection still allocated. 07-06 11:55:16.934: W/SingleClientConnManager(1049): Make sure to release the connection before allocating another one.
I did some searching around stackoverflow and I tried adding the following code as people recommned:
response.getEntity().consumeContent();
but I am still getting the some warnings. Here is the code to my post request function:
private void sendRequest() {
// TODO Auto-generated method stub
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", username));
nameValuePairs.add(new BasicNameValuePair("password", password));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
status = response.getStatusLine().getStatusCode();
response.getEntity().consumeContent();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
What do you guys think I am doing wrong?
I could solve this issue by following this solution: http://tech.chitgoks.com/2011/05/05/fixing-the-invalid-use-of-singleclientconnmanager-connection-still-allocated-problem/
Hope this solves your problem.