开发者

Android networking - best practices

I'm developing an application with lists and forms which most of them are loaded from t开发者_如何学编程he web (I have a JSON server I make requests). I'm using AsyncTasks to retrieve all the data. I was wondering if it's the best way to deal with networking, since the application can be sent to background (and in some cases, killed by the OS) by receiving a call, SMS or simply by having the home buttom pressed. What happens to AsyncTasks when the application goes background? Are they killed, suspended or something? I don't want to have my forms and lists half-loaded. Should I use services instead of AsyncTasks?

Thanks for any help.


Your AsyncTask will stick around, although it would be nice if you could tell the task to wrap things up ASAP as soon as your activity goes to the background.

You typically don't need a service unless you're planning something long-term, i.e. something that keeps running in the background.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜