Solution to Android exception java.lang.illegalstateexception
Android exception details
For this exception, I encounter the following two situations: 1. Java.lang.illegalstateexception: no wrapped connection. 2. Java.lang.illegalstateexception: adapter is detached
reason:
1. A single thread can execute one request at a time. If multiple threads are used, connection timeout will occur when multiple requests are executed at the same time. 2. HTTPCONNECTION does not have the concept of connection pool. How many IOS will be established for how many requests. In case of huge access, the IO of the server may be exhausted. 3. It is usually because httpclient accesses different threads of a single instance or does not close the httpresponse of InputStream.
Solution: get httpclient thread safety
Pre resolution code:
Code after resolution:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.