开发者

Accesing UI thread with Async task

I wonder which approach is better/cleaner:

Should I pass Context on the constructor and have onPostExecute access the UI thread?

or

Extend my Task class in the UI thread and override onPostExecute (no need to pass Context)?

Passing Context into AsyncTask feels 'd开发者_如何学Pythonirty' but I don't know whether it's ok 'polluting' the UI class.


I usually use inner classes for this and see no reason why this should be a bad solution, assuming the class implementation is specific to the class into which it's nested.


If you are not going to extend your class in future with another class, then extend it. But I'd rather choose passing the context in the constructor.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜