What are Services in Xamarin.Android?

Technology CommunityCategory: XamarinWhat are Services in Xamarin.Android?
VietMX Staff asked 3 years ago

Service is an application component that allows a user to run long operations that do not require user interaction. Services are broadly classified into Started and Bound Service.

  • Started Service is one which is invoked by call StartService(). Once started the service can run indefinitely in the background, even after the component that started it is destroyed. Usually, a started service performs a specific operation (like downloading a file) and stops itself. A  User-defined Started Service can be created by either extending the Service class or by extending the Intent Service. An Intent Service is a special type of Service which stops itself automatically after completing the task assigned.
  • Bound Service is created when the application component calls BindService() to bind to a service. Bound Service is like a Client-server interface that allows components to interact with the service, send requests, get results, etc. A Bound service can be accessed by the components within an application and also by components residing in other applications (if it is exported/exposed). Bound Services only keep running till they have a client associated with it. When all clients Unbind the service the service stops.