Best way to manage the ProgressDialog from AsyncTask

后端 未结 2 1844
太阳男子
太阳男子 2020-11-28 12:37

I would like to use the AsyncTask for manage some business logic in my application. What is the best pattern for using the onProgressUpdate(...) me

2条回答
  •  野性不改
    2020-11-28 13:03

    1. Solution number one is probably how I would handle it - That is the way of the Android framework. A twist to this solution (and probably how I would handle it, if the AsyncTask couldn't fit into the Activity-class) I would pass a Context as the parameter instead, and then instantiate and show the ProgressDialog in onPreExecute.

    2. Solution number 2 is basicly the same as creating the dialog as an inner class - so you might aswell do that if you go for this one.

提交回复
热议问题