I am using multiple asynctask in my code to make multiple http requests , and I have to use the same client for them. But android is not allowing me to do so. It is asking me to close the connection first and then start a new one again.
Asked
Active
Viewed 1,078 times
0
-
Please post the exact message(s). It would also help to see your code. – Ted Hopp Jul 18 '12 at 17:30
1 Answers
0
nd I have to use the same client for them
why?
It is asking me to close the connection first and then start a new one again.
Well, then do what it says. Basically it tells you clearly you are (ab)using httpclient which is not ready to do what you want it to. Luckily there are other httpclients available which you should use instead of builtin one. Or, depending on target sdk, use http://developer.android.com/reference/android/net/http/AndroidHttpClient.html

Marcin Orlowski
- 72,056
- 11
- 123
- 141
-
if i close the connection and the subsequently the client, my app simply restarts. Is it a cookie issue, because when i start another activity and make the request it works fine, but making 2 requests in the same activity creates an issue for me – Prashant Tiwari Jul 18 '12 at 20:57
-
If cookie issue means you need to hand your server certain cookie, then you can sync all cookies from one http client's cookie jar with other client. See http://stackoverflow.com/questions/3587254/how-do-i-manage-cookies-with-httpclient-in-android-and-or-java or related – Marcin Orlowski Jul 20 '12 at 09:10