I used the HttpComponents library that Android comes with. I wrote 2 classes to send parameters with GET and POST and get InputStream or String from the server. Everything worked fine: every download in the stream, start, pause, resume ... But today I started two downloads at the same time, and none of them finished.
I have a googled solution, and I have seen that Android comes with HttpCore 4.0-beta2. Yes, he is very old. It was released on July 1, 2008, and Android has not updated it since ...
I rewrote my classes, but now I use HttpURLConnection, and I can upload two files at the same time.
Well, that was a warning to you if you plan to use the HttpComponents on Android. Now my question. I want to import a new version 4.1 into my project. I added banks to the constructed path, but now, how can I use these banks if the new (4.1) and old (beta2, 4.0) packages are the same?
Thank.
solvable
You must create DefaultHttpCLinet using ThreadSafeClientConnManager:
HttpParams parameters = new BasicHttpParams ();
HttpProtocolParams.setVersion (parameters, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset (parameters, HTTP.UTF_8);
HttpProtocolParams.setUseExpectContinue (parameters, false);
ConnManagerParams.setMaxTotalConnections (parameters, MAX_CONNECTIONS);
SchemeRegistry schReg = new SchemeRegistry ();
schReg.register (new Scheme ("http", PlainSocketFactory.getSocketFactory (), 80));
client = new DefaultHttpClient (new ThreadSafeClientConnManager (parameters, schReg), parameters);
UPDATE . You can also use AndroidHttpClient. With this class you do not need to use ThreadSafeClientConnManager
AndroidHttpClient client = AndroidHttpClient.newInstance ("Android");
Additional Information
source
share