Best way to request data from server

后端 未结 3 2007
离开以前
离开以前 2020-12-20 06:53

I need to fetch some data from my server in order to make my app work. In order to do that, I will be using POST. As far as I know, I have to request that data in a thread w

3条回答
  •  没有蜡笔的小新
    2020-12-20 07:28

    The error you are getting is because of accessing UI elements from background thread.

    AsyncTask is a Thread pool based api that runs your task in a seperate thread ,but your UI part runs in a thread usually called UI thread, to update any changes to ui put the logic onPostExecute()

    NOTE: Use okhttp to get consistent http api, it also supports http2.Their github wiki is very helpful, check here for examples.

提交回复
热议问题