Tasker
Home
Direct Purchase
Download
TaskerNet
Home Automation
Usage Examples
Pre-made Projects
FAQs
Guides
Reviews
Wiki
Plugin List
Forum
Forum/Support
Legacy Forum
Userguide (5.0+)
Index: en es fr zh
1 Page: en
More
Join
AutoApps
Developers
History
Privacy Policy
Release Notes
Next Version
Feature Requests
Report Issues
Patreon

Developers: Tasker Plugin Introduction

What's Tasker ?

Tasker is an app which lets users perform actions based on conditions being met or events occuring. For example, the user may stipulate when an SMS arrives from my brother (event), and the day is Friday (condition), send an SMS back saying 'try again tomorrow' (action)

What's A Plugin ?

Plugins are full-blown external apps which allow developers to add to the event, states and actions which Tasker natively supports. Plugins can also easily be added to existing apps via an extra broadcast receiver (for signalling) and activity (to allow the user to edit their data).

Some important characteristics are:

  • the plugin UI is presented via the Tasker UI just like native Tasker functions
  • the plugin developer needs no contact with the Tasker developer to write, change, publish and/or sell their plugin app
  • if no Tasker extensions are used, the plugin will also be compatible with other profile apps which use the same protocol e.g. this one.

Types Of Plugin

The type of plugin you implement depends on what functionality you want to offer.
  • action plugins (also called a setting plugin) will extend the number of things that a user can cause Tasker to do e.g. to allow the user to send an email
  • condition plugins will extend the conditions that the user can specify e.g. data usage is over a threshold
  • event plugins will extend the events that the user can specify e.g. the device has been dropped

Getting Started

Check out the Tasker Plugin Library.

ALL INFO BELOW IS DEPRECATED. PLEASE USE THE PLUGIN LIBRARY ABOVE INSTEAD. OLD INFO BELOW WILL BE KEPT HERE FOR REFERENCE.

  1. for an action plugin, download the toast sample project, otherwise the display sample project
  2. unzip it
  3. in Eclipse, select File / Import / Existing Android Project and browse to the directory
  4. click OK and select the 3 projects which are presented
  5. after import, build first the locale-api project and then build and install the display or toast projects

Action Plugins

You should now be able to see your plugin in the Plugin category when you add an action to a task in Tasker.

The most important source code files in the plugin are:

  • EditActivity.java
    this will be started by Tasker when the user asks to create an instance of your plugin by selecting it in the Add Action dialog. It needs to return as result an intent with a Bundle of data. For instance, the Toast sample project returns a Bundle stipulating what the flashed message should say.
  • FireReceiver.java
    its onReceive() function will be called when your plugin should perform whatever action was configured by the user. In the Toast sample project, the configured message is flashed. To this end, the same Bundle configured in the EditActivity is passed to it.

Condition Plugins

You should now be able to see your plugin in the Plugin category when you add a state context to a profile in Tasker.

The most important source code files in the plugin are:

  • EditActivity.java
    this will be started by Tasker when the user asks to create an instance of your plugin by selecting it in the Add Context / State / Plugin dialog for a profile. It needs to return as result an intent with a Bundle of data. For instance, the Display sample project returns a Bundle stipulating whether the display should be on or off.
  • QueryReceiver.java
    its onReceive() function will be called when Tasker wants to know whether the condition is currently active or not. The same Bundle configured in the EditActivity is passed to it so that it knows which condition parameters the user has configured.

When the plugin notices that the condition has changed (the display has gone on or off in this case), it sends Tasker a REQUEST_QUERY intent, which in most cases will result in Tasker asking the plugin for the current status.

Event Plugins

Event plugins are a Tasker extension (from Tasker version 4.3) to the plugin protocol. As such, you need to make a the following changes to the Display sample project:
  • add TaskerPlugin.hava to your project
  • in AndroidManifest.xml, change
       com.twofortyfouram.locale.EDIT_CONDITION
    to
       net.dinglisch.android.tasker.ACTION_EDIT_EVENT
  • in BackgroundService.java, add
       TaskerPlugin.Event.addPassThroughMessageID( INTENT_REQUEST_REQUERY );
    before each sendBroadcast() call.

  • in QueryReceiver.java, add
       if ( messageID == -1 )
          setResultCode( com.twofortyfouram.locale.Intent.RESULT_CONDITION_UNKNOWN );
       else
    before the line
       if (isScreenOn)

When you rebuild the project, you should now be able to see it in the Plugin category when you add an event context to a profile in Tasker.

The most important source code files in the plugin are:

  • EditActivity.java
    this will be started by Tasker when the user asks to create an instance of your plugin by selecting it in the Add Context / Event / Plugin dialog for a profile. It needs to return as result an intent with a Bundle of data. For instance, the Display sample project returns a Bundle stipulating whether the event will occur when the Display goes on or when it goes off.
  • QueryReceiver.java
    its onReceive() function will be called whenever the plugin tells Tasker that an event has occured (by sending Tasker a REQUEST_QUERY intent).

The same Bundle configured in the EditActivity is passed to it so that it knows which event parameters the user has configured.

Next Steps

It's recommended that you play around with the interaction between plugin and host a little and then read the technical documentation for the base specification. If you are interested in some other Tasker extensions (e.g. variable support, synchronous actions so Tasker knows when your action plugin has finished) see here.