Nguyen Dai Son
Nguyen Dai Son

Reputation: 269

Remote Service Vs. Local Service

Dear All, I am a newbiew to Android. I had read a lot of articles about Android Service but I am not clearly understanding what defferent between Local Service and Remote Service (except for "Local Service run in the same process as the lunching activity; remote services run in their own process" - The Busy Coder's Guide to Android Development - Mark L. Murphy ).

  1. Please shows me what different between Local Service and Remote Service.
  2. What's the advantage/disadvantage of using Local Service.
  3. What's the advantage/disadvantage of using Remote Service.

Thanks & best regards Dai Son

Upvotes: 23

Views: 11849

Answers (4)

us_david
us_david

Reputation: 4917

I hope I can clarify the issue from my own experience:
LocalService:
To be created to serve local applications (activities) by providing background execution or performing some specific software functionality. Not accessible by other applications not in the same package except through intent. Local service normally lives in the same process as the companion activity. But it can potentially have it's own process if needed.

Remote Service
This type of services normally design and implement software functionality to be used by other apps. Android system services (wifi/gps/usb/etc.)are the main examples in this category. If you need provide functionality to be used by other apps, you need to develop a remote service which implements remote binding, intent (through startCommand) or other IPC mechanism.

Remote or local it all depends on your need and application.

More readings:
Android Official Document on service binding.

Cheers,
David.

Upvotes: 0

Abhijit Chakra
Abhijit Chakra

Reputation: 3234

The difference between remote service and local service is: Local service runs in the same process and remote service runs in different process and may be in different application.

You can access a remote service which is running in the different application but you can't access a local service that is running in a different application.

Upvotes: 2

Abhijit Chakra
Abhijit Chakra

Reputation: 3234

Local service means it runs in the same process probably in the same application. You can start a service using the method startService() and you can stop the service by using the method stopService(). These two life cycle methods or Service And remote service are generally run in a different application. you can access them by writing AIDL Interfaces and you can attach to a remote service by using binder.

Upvotes: 0

Falmarri
Falmarri

Reputation: 48577

Your description is exactly the difference between a local and remote service. There's nothing more to say. You will almost never want to use a remote service.

Upvotes: 9

Related Questions