Headless Js Task Service
Base class for running JS without a UI. Generally, you only need to override getTaskConfig, which is called for every onStartCommand. The result, if not null
, is used to run a JS task.
If you need more fine-grained control over how tasks are run, you can override onStartCommand and call startTask depending on your custom logic.
If you're starting a HeadlessJsTaskService
from a BroadcastReceiver
(e.g. handling push notifications), make sure to call acquireWakeLockNow before returning from BroadcastReceiver.onReceive, to make sure the device doesn't go to sleep before the service is started.
Functions
Called when a JS task finishes (i.e. when HeadlessJsTaskSupportModule.notifyTaskFinished is called, or when it times out), on the UI thread.
Called when a JS task is started, on the UI thread.