android.os.NetworkOnMainThreadException in AsyncTask's doInBackground

前端 未结 2 881
太阳男子
太阳男子 2020-12-02 00:31

Why do I get in an AsyncTask which should a android.os.NetworkOnMainThreadException? I thought that an AsyncTask is the solution to that problem. The exxeption is on line 7.

2条回答
  •  独厮守ぢ
    2020-12-02 01:08

    By calling doInBackground() directly, you are not actually using the AsyncTask functionality. Instead, you should call execute() and then use the results by overriding the AsyncTask's onPostExecute() method as explained in the Usage section of that same page.

提交回复
热议问题