Thanks Giampaolo. On Aug 31, 9:09 pm, "Giampaolo Tomassoni" <[email protected]> wrote: > > Service class is used to run something in background but for that we > > have to create a thread in the onStart function of the subclass of the > > Service. I think same thing can be done by creating a thread in > > Activity class then what is the use of the Service component? > > I may be wrong, but it seems to me a Service doesn't follow the same > lifecycle of an application (or, better sayd, an Activity), such that it may > keep running whenever an activity may not. > > In example, while when you switch to another activity the running > application may be asked to stop execution and even release context, a > Service doesn't follow this pattern and it can't stop this way. > > Then, a Service is more or less like a "daemon" under Linux. I guess its > usage patterns are more or less like the daemon ones: it may be used to > provide background functionalities. Imagine, in example, that your Android > device carries a GPS. If you want to keep track of your daily journey, you > need a service which periodically receives GPS data and persists it > somewhere. > > If you attempt doing that with a classic activity, you end saving only part > of your path, which is only when that activity is active.
-- You received this message because you are subscribed to the Google Groups "Android Discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/android-discuss?hl=en.
