开发者

should we use services for network connections in android

should we use android services for netw开发者_JS百科ork connection? if yes please provide me a sample.


It depends what kind of network connection you are using. If you just want to fetch some data from the web I would recommend using a AsyncTask. If you are opening a port to a distant server for a longer living connection like a chat application would use you may want to look at a service.


In general you're better of just wraping the communication in an AsyncTask. Then you can easily handle for instance progress updates and canceling of requests etc. Services should be reserved for heavy lifting.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜