Services
- A Service is an application component that can perform long-running operations in the background, and it does not provide a UI, and it continues to run in the background even if the user switches to another application
- In Service, You can override onStartCommand() to allow components to start it and onBind() to allow binding
- Services are declared in the Manifest file
- A service runs in the main thread of its hosting process, you should create a new thread within the service to complete operations that take long time to avoid blocking UI thread.
- The service life cycle for both bound and started services are illustrated in this Google docs diagram
- Services classes and start modes are illustrated in the following diagram:

*Note: For Intent Service, If you decide to also override other callback methods, such as onCreate(), onStartCommand(), or onDestroy(), be sure to call the super implementation so that the IntentService can properly handle the life of the worker thread.
Reference: https://developer.android.com/guide/components/services.html#Basics
No comments:
Post a Comment