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

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

c# - Making TableLayoutPanel Act Like An HTML Table (Cells That Resize Automatically Around Text) -