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

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -