Android - android.os.NetworkOnMainThreadException

后端 未结 8 1193
迷失自我
迷失自我 2020-11-22 08:15

I have this exception and I was reading a thread on this, and it seemed confusing:

How to fix android.os.NetworkOnMainThreadException?

I already added this l

8条回答
  •  情歌与酒
    2020-11-22 08:55

    You can just create Async class as below

    class Retrievedata extends AsyncTask {
    @Override
        protected String doInBackground(String... params) {
             try{
                    //Your code 
                    }
            return null;
        }
    }
    

    You can just put your all code inside doInBackground method

提交回复
热议问题