Following Android HTTP Example / Tutorial - Issue Implementing Async Task for Network Activity

前端 未结 1 591
情书的邮戳
情书的邮戳 2021-01-29 11:23

I\'m attempting to follow a tutorial regarding posting HTTP data however its force closing on the main thread due to network activity on the IO thread so I\'ve attempted to impl

相关标签:
1条回答
  • 2021-01-29 12:15

    NetworkOnMainThreadException

    You are getting exception because you are doing network operation on main thread which is not allow android version >= 3.0.

    Use AsyncTask to do network operation.

    Do your network operation in doInBackground() method.

    Read android docs for AsyncTask.

    0 讨论(0)
提交回复
热议问题