bundle.putString("foo", "bar");
service.putExtras(bundle);
-getApplicationContext().startService(service);Caveats #
- By default, your app will crash if you try to run a task while the app is in the foreground. This is to prevent developers from shooting themselves in the foot by doing a lot of work in a task and slowing the UI. You can pass a fourth
boolean argument to control this behaviour. - If you start your service from a
BroadcastReceiver, make sure to call HeadlessJsTaskService.acquireWakeLockNow() before returning from onReceive().
Improve this page by sending a pull request!