HttpURLConnection disconnect doesn't work in Android -


the method disconnect httpurlconnection seems not work properly. if execute following code:

url = new url("http:// ..."); connection = (httpurlconnection) url.openconnection (); connection.setrequestmethod("post"); connection.setrequestproperty("content-type", "application/x-www-form-urlencoded"); connection.setusecaches(false); connection.setdoinput(true); connection.setdooutput(true); connection.connect(); // code connection.disconnect(); connection.setdoinput(false); // -> illegalstateexception 

i illegalstateexception when call method setdoinput. exception says:

already connected

it sounds you're trying reuse connection? i.e. altering request properties after you've disconnected server, ready make connection.

if case, create new httpurlconnection object.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -