Saturday 5 January 2019

urlConnection.connect() works only in AsyncTask - android




I am connecting to a web service using



   urlConnection.connect();


This works only in AsyncTask. I am not able to execute the above statement on plain activity (without AsyncTask )



Is it the behavior by design, or I am missing something.




By the way, this is my first question


Answer



Welcome to stackoverflow. please use google search and stackoverflow search before posting a question. the chnaces are big, that someone else had already asked your question. stackoverflow rules



Network communications must be done in seprate Thread in android.
Read more about it here developer wiki


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...