Pre-made Projects
Userguide (5.0+)
Index: en es fr zh
1 Page: en
Privacy Policy
Release Notes
Next Version
Feature Requests
Report Issues

Plugins With Services

From version 5.1.5b, Tasker will use IntentServices to call plugins if available. This will make plugin integration faster and more reliable.

If you already implemented a plugin for Tasker, here's what you need to do to make Tasker call your plugin via IntentServices.

  • Update Tasker to at least version 5.1.5b (you may need to join the beta)
  • Use the new TaskerPlugin.java
  • Add the PluginResultReceiver class to your project (keep its original package name)
  • Add the IntentServiceParallel class to your project. You can use any package name for it. This is used so that multiple Tasker actions for your plugin can run simultaneously.
  • Add Services in the manifest with the same com.twofortyfouram.locale.intent.action.FIRE_SETTING and com.twofortyfouram.locale.intent.action.QUERY_CONDITION intent filters as your existing broadcast receivers and make sure they're exported (android:exported="true")
  • Make those Services extend IntentServiceParallel and run the same code as you were running in your broadcast receivers but with some minor differences:
    • You can use blocking actions (like making web requests) since you're running in a background thread
    • In the FIRE_SETTING Service, if you want to return variables, always call TaskerPlugin.signalFinish instead of setting the result directly like it was possible before.
    • In the QUERY_CONDITION Service instead of doing
      to set the result code and
                      TaskerPlugin.addVariableBundle( getResultExtras( true ), varsBundle )
      to set the result variables you have to do
                      Bundle resultBundle = new Bundle();
                      TaskerPlugin.addVariableBundle( resultBundle, varsBundle )                
                      TaskerPlugin.Condition.getResultReceiver(intent).send(resultCode, resultBundle);

Some notes:

  • If a plugin action's timeout is set to 0 the plugin will still be called via broadcast.
  • If a plugin targets API 26 or above and the device is running API 26 or above and the plugin is battery optimized, Tasker will start the Service in the foreground. It's the plugin's responsibility to make the service is brought to the foreground in this situation or else it'll crash.