Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between an Android Activity and Service

Tags:

android

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.

like image 806
Prasath Avatar asked Feb 19 '11 09:02

Prasath


People also ask

How are activities and services different?

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.

What does Android activity mean?

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.

What is an Android service?

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.


1 Answers

Activity is a GUI and service is non-gui thread which can run in the background. Some more details here.

like image 176
Drakosha Avatar answered Oct 09 '22 16:10

Drakosha