User Tools

Site Tools


working_with_tasker

Overview

Built-in Tasker support starts with LLX 10.5b1. This support consists in

  • launching Lightning actions from a Tasker task
  • launching Lightning scripts from a Tasker task (starting at 12.4b2)
  • setting variables inside Lightning from a Tasker task (starting at 12.5b1)
  • launching Tasker tasks from Lightning, through scripting

Running Lightning actions from a Tasker task

All available Lightning actions can be used. This is similar to starting a Lightning action shortcut. In Tasker, create or modify a Task, add an action, select Plugin, then select Lightning Action. Once the action has been added edit its configuration: the Lightning action menu is displayed so that you can select one.

Running Lightning scripts from a Tasker task

Starting at version 12.4b2, it is possible to directly select a script as a plugin action in Tasker. This is equivalent to selecting a Lightning action and then select “Run a script”. In addition, when selecting the script, there is an option to select where to execute the script (in the desktop, in the app drawer, in the lock screen or in the background).

When running a Lightning script from Tasker it is possible to pass data to Lightning with variable replacement. These data can be retrieved in the script using Event.getData(). For instance, if you script is

alert(LL.getEvent().getData());
Then calling this script from Tasker with the data %TIME will display a dialog in Lightning with something like 11:17

Setting variables inside Lightning from a Tasker task

For 12.5b1 and above. Variables are primarily used in bindings (expert mode). They are used to animate items properties, such as position, transparency, colors, and so on. These variables can be set inside Lightning or from third party apps. In particular Lightning provides a Tasker plugin to set its own variable. When adding an action in Tasker, select Plugin, then select Lightning Variable. You then need to enter the name of a variable (or pick an existing one), then enter the value for the variable.

Starting Tasker task from Lightning, though scripting

Tasker can only be invoked from scripting at the moment. This is done using the TaskerIntent and ActionCodes classes and the LL.sendTaskerIntent() method.

Important notes on background scripts

Scripts run in the background are executed in a special context. Since there is no UI, not all features are available. For instance it is not possible to get the cell size of a container since it is not displayed, nor it is possible to get the list of open folders. Keep in mind that scripts in background are not executed for the desktop, the app drawer or the lock screen, but “outside”, without a screen. It is allowed to change items and container properties, but not to navigate into a desktop or open a folder.

The API documentation mentions cases where a given method is not supported in background mode.

When a script is run in the background, the Lightning Launcher app may be started by the Android system (it will remain invisible), and it may be stopped after a while. As a consequence changes made to items that are not persistent will be lost.

Calling an existing task

The simplest way to call a Tasker task is:

LL.sendTaskerIntent(new TaskerIntent("MyTask"), false);
Where MyTask is the name of a task already defined in Tasker.

Requesting Tasker to execute a task on the fly

This method does not need to configure a task in Tasker. You can elaborate a sequence of actions and request Tasker to execute it.

var i = new TaskerIntent("Say");
i.addAction(ActionCodes.SAY);
i.addArg("hello");
i.addArg("com.google.android.tts:en-gbr");
i.addArg(0);
i.addArg(5);
i.addArg(5);
i.addArg(true);
i.addArg(false);
i.addArg(false);
LL.sendTaskerIntent(i, true);
alert("done");
This sample will trigger speech synthesis. Arguments need to be specified according to the order found in the Tasker UI or documentation for the given action. More documentation on TaskerIntent can be found here: http://tasker.dinglisch.net/invoketasks.html

working_with_tasker.txt · Last modified: 2015/05/15 10:06 by pierrox