开发者

asynchronous helper class android

The application Im working on relies heavily on data retrieved from a server so Im using AsyncTask mainly to fetch data from the server a开发者_JAVA百科nd update the UI. The problem is that it is resulting in a huge amount of code living in the main activity for all the tasks that are needed and I would like to break the code out into helper classes like I would do in C#, is it possible at all to have say a helper class called OfferHelper with a method getOffers() that will execute asyncronously and return server data.

So what I want to do is in the main activity call OfferHelper.getOffers() but not have it block the ui, Ive tried using asynctask in the actual helper classes but it seems like it wasnt designed to work like that.

Has anyone tried to do this before,could offer any advice?

many thanks


There shouldn't be any problem with that. Simply send a reference to the context (Activity.this) so you can do whatever you need. Post your code so I can see the specific problems

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜