Update progressbar from AsyncTaskLoader?

前端 未结 6 1687
粉色の甜心
粉色の甜心 2021-01-31 05:30

When using a AsyncTaskLoader how would you update a progressbar showing the status as it is being updated? Normally you wait for the callback to remove when done, but how to do

6条回答
  •  梦毁少年i
    2021-01-31 06:24

    I'm using this with my AsyncTaskLoader, inside of loadInBackground

    runOnUiThread(new Runnable() {
        public void run() {
            //UI code
        }
    });
    

    However, this doesn't work with an configuration change (like orientation change). I'm not convinced AsyncTaskLoader is the best to use if you need to update the UI, but it works best when handling configuration changes. I don't know why they created both an AsyncTaskLoader and an AsyncTask each with their own tradeoffs. Just frustrates and confuses developers. On top of that AsyncTaskLoader has very little documentation.

提交回复
热议问题