Search code examples
androidhttpclienturlconnection

URLConnection or HTTPClient: Which offers better functionality and more efficiency?


I am looking to create a login form for an Android application. I want to use a post method to send information to the server side where it is handled by a PHP file; which in turn validates the parameters and sends back a response.

I've looked through implementations using Apache HttpClient and URLConnection, and they are very similar. Which is more efficient for use within an Android app?


Solution

  • I believe in this case it's up to whichever API you find more natural. Generally, HTTPClient is more efficient inside a server side application (or maybe batch application), because it allows you to specify a multithreaded connection pool, with a max number of total connections, and a max per host connection count (which ensures concurrent connections to the same host don't get serialized (a problem with HttpUrlConnection)). But in an android app, you'll probably only be making a single connection at a time, so this doesn't matter.