Hello AsyncTask is not a member of activity. in separate class. how c开发者_Go百科an i call function of activity from AsyncTask ? thanks
You can pass an instance of your activity in the constructor of your AsyncTask. But be sure to call the methods of activity only inside onPreExecute()
and onPostExecute()
methods, becuase they run on the UI Thread.
If you want to call some activity code while doInBackground()
, then you should create a Handler
and pass it to the AsyncTask
, because you can not modify the ui from non UI thread.
精彩评论