A background service that runs when the application is placed in the background.
The BackgroundService is created by
The background service runs when the application is placed in the background and will continue to run until one of the following occurs:
The application resumes.
The service is stopped with the
The OS terminates the service for one of the reasons discussed in "Background Service Limitations", below.
Note that there are several issues with the current implementation of background services:
The background service runs when the Application is placed in the background and will
continue to run until the service is stopped with the
stop method, however, this also
unregisters the service.
unregister on the background service unregisters the service, but does not
stop the background task under which the service was launched. This can lead to having
multiple tasks running in the background.
register multiple times with the same URL results in multiple instances of
the same service being run.
These issues will be addressed in a future release. To work around these issues, the application must:
Unregister the background service when the application resumes.
Re-register the background service when the application pauses.
Note that even with these workarounds, the background service is subject to limitations imposed by the operating system. In particular:
The OS limits the total amount of time the background service can run for after the application is suspended, typically to no more than 10 minutes.
The OS may terminate the background service at any point to reclaim resources.
Adds the specified callback as an event listener for the named event.
Fires a synthesized event to any registered listeners.
Gets the value of the url property.
Removes the specified callback as an event listener for the named event.
Stops the service from running during the current background session to conserve resources.
Unregisters the background service.