Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Service: Process vs. Not

What are the practical differences between putting a service in a separate process or keeping it in the app's main process? What would each scenario be used for?

like image 856
Jake Avatar asked Nov 03 '10 02:11

Jake


People also ask

What is difference between process and service?

A process is an instance of a particular executable (.exe program file) running. A service is a process which runs in the background and does not interact with the desktop.

What is process and service in Android?

remember, android is linux: process = any running program. e.g. something with a PID. service = roughly equivalent to a daemon. something running in the background with no direct user interface.

How check service is running or not in Android?

You can do this by making your own Interface where you declare for example " isServiceRunning() ". You can then bind your Activity to your Service, run the method isServiceRunning(), the Service will check for itself if it is running or not and returns a boolean to your Activity.


1 Answers

When a service is running in the main process it will be stopped in case your application crashes for whatever reason. Put a service into it's own process is reasonable for some services which can be used from different applications or services which should run independently from your main app.

like image 164
Denys Nikolayenko Avatar answered Nov 03 '22 19:11

Denys Nikolayenko