Started service
As described previously, a started Service is a service that is initiated when the Context
method startService()
is invoked by any entity on the system that has access to a Context object or is a Context itself, such as an Activity:
ComponentName startService(Intent service)
Note
An Intent is a messaging object that can carry data (action, category, extras, and so on) and that you can use to request an action from another Android component.
The startService()
function basically starts a service with an intent, and returns to the user a component name that can be used to verify that the correct service was resolved and invoked.
To simplify the Service resolution, we pass an Intent created from the current context with the Service class that needs to be started:
startService(new Intent(this,MyStartedService.class));
When the system receives the first startService(intent
) request, it builds up the Service by calling onCreate()
and forwards the intent from the first startService...