Saturday, January 5, 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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...