I have a server call to fetch JSON response. Here is the code snippet.
convertStreamToString(InputStream) read json text from the stream and returns a string text. For holding the state of the user session, same httpClient reference is being used.
The problem arises when a service starts working. It accesses the httpclient object and in turn InputStream instance. By the time, the user moves to other screen, putting service to run background. Exception is thrown when InputStream already in use is called for.
The reason being, the socket is still used by the Service class. I have heard of ThreadSafeClientConnManager class. However, not really sure if it suits in here.
Let me know in case you need more details.
Thanks in advance!