Am having a great confusion between activity and service. My aim is to run a music player. In most of the document said, to run a background work for an activity you should use service. But its possible to invoke a player from a thread created by an activity itself. Moreover, the thread wont destroy even if the activity destroyed.
If so, what is the usage of service here ? Why should we use service and when to use service ?
Plz clarify my doubt !
Thanks in advance.
Activity is a GUI and service is non-gui thread which can run in the background. Some more details here. IntentService is running in background while service is running on GUI thread.
An activity provides the window in which the app draws its UI. This window typically fills the screen, but may be smaller than the screen and float on top of other windows. Generally, one activity implements one screen in an app.
An Android service is a component that is designed to do some work without a user interface. A service might download a file, play music, or apply a filter to an image. Services can also be used for interprocess communication (IPC) between Android applications.
Activity is a GUI and service is non-gui thread which can run in the background. Some more details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With