开发者

call function from asynctask

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜