I am a beginner of Android Programming, and when I learn something about Service ,the problem has become.
We all know that the UI thread cannot run a long-time process, so we should run them in a new thread, and immediately ,we have recognised that something about Handler AsyncTask and Service even send a BroadCast when the task has been finished.However, I am not sure when to use them.
For example, we often using an activity to login, when the data should be posted, maybe post to the remote server, it may cost a long-time,we cannot write something in LoginActivity maybe in an AsyncTask or a Service to do that.But which is the better choice ？
As a general rule:
In your case, the expectation of the user is important. The user tries to login and waits in an activity for the responds of the server. You should send the request to the server in an AsyncTask and e.g. show the user a waitscreen until the response is there ("Try to login"). So the UI is still responsive but the user clearly knows, that he has to wait for a response.