Skip to content Skip to sidebar Skip to footer

Problems With Httpmethod.releaseconnection() And Entityutils.consume(entity)

I'm having a problem: I've just copied the following code from NetBeans to Eclipse (an ADT project). I've imported all the same librarys I used in NetBeans, but I have 2 errors, in

Solution 1:

Android comes with a prepackaged version of Apache HttpClient that doesn't have those methods. They are no longer supporting development and that code is outdated.

The Android team recommends that you use HttpUrlConnection for new code instead of HttpClient. More information can be found at this blog on the Android Developers site.

Solution 2:

I think you should follow a simpler example, as this one seems to be meant to upload files (multipart/form-data), but regarding the specific problems in your code:

  1. Instead of EntityUtils.consume(entity); you can do entity.consumeContent();http://developer.android.com/reference/org/apache/http/HttpEntity.html

  2. The HTTPRequest classes (HttpPost, HttpPut) don't have any releaseConnection() method. Probably because they don't need to be released (somebody correct me if I'm wrong). That method is usually applicable for persistent connections which is not the case here.

Solution 3:

Check your imports; What version of Apache HttpComponents are you using in your new project?

Post a Comment for "Problems With Httpmethod.releaseconnection() And Entityutils.consume(entity)"