Reputation: 265
should we use android services for network connection? if yes please provide me a sample.
Upvotes: 0
Views: 282
Reputation: 21081
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.
Upvotes: 0
Reputation: 189484
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.
Upvotes: 1