Intents are Android's main method for allowing apps to communicate with each other and share data.
Intents are for advanced users. This document is not intended to explain how intents work, but
how to use Tasker's intent facilities.
You can find information about intents and details of several built-in Android intents on the Android SDK
Tasker allows you to send arbitraty intents using the Send Intent action in the
Misc category. This allows
you to provoke behaviour in other apps, when you know the particular form of intent they
are designed to respond to.
Send Intent Parameters
Note that any parameter specified except Extras will reduce the set of possible receivers
of the intent.
What the sender would like the receiver to do with the data.
Gives additional information about the action.
From the developer reference: "This is used to create intents that only specify a type and not data, for example to indicate the type of data to return."
Can't be used together with a Data specification.
The main data specification in the form of a URI.
Can't be used together with a Mime-Type specification.
Any additional data to send with the intent.
The extras must be in the form of a single colon-separated key and value.
If the value can be parsed as an integer, long (integer ending in L), floating point number, double (float ending in D) or boolean (true/false) it will be treated as one.
The value can also be forced to a simple type (long etc) or
Uri via casting.
The name of a Java object created via the Java Function action which is of type
Parcelable can also be used (e.g. a
If none of the above apply, the value will be treated as a
- address: (Uri) http://a.b
- bunchofvalues:mybundle (where mybundle is the name of a Java object of type Bundle)
- simple.string.example:hello there!
Allow specification of a particular package and/or class within the package to
restrict the broadcast to.
The type of Android component which should receive the intent.
Finding App Intents
Many intents that an app listens for are declared in its package manifest
(called AndroidManifest.xml). You can view details of those intents
using the aapt tool that comes with the Android SDK like this:
aapt dump xmltree example.apk AndroidManifest.xml
Look for Intent Filter elements.
It's not (easily) possible to determine which intents an app listens
for dynamically (i.e. while the app is running).
Tasker allows you to receive a large range of intents, sent by apps or the system, using the Intent Received event in the System category.
For each event you create, Tasker sets up a corresponding
Intent Filter object.
- Tasker can only receive intents which
are sent to broadcast receiver components, not to activities
- some intent senders require that a corresponding intent filter is specified statically
(i.e. in an Android Manifest). Those intents cannot be received.
- intents which are broadcast with a specification of a particular
package component to receive it cannot be received.
Intent Received Parameters
If specified, the received intent must have also that action specified.
Any categories specified in the received intent must also be specified
in the Tasker event. Note that this is logically different to the
situation for the Action parameter.
If any schemes are included in the filter, then an Intent's data must be either one of these schemes or a matching data type. If no schemes are included, then an Intent will match only if it includes no data.
If a type is specified, then an Intent's data must be the same,
or match the Scheme parameter. If no Mime Type is specified,
then an Intent will only match if it specifies no Data.
If the intent is part of an ordered broadcast, then the priority
specified here will affect whether this event will receive the intent
before or after other listeners.
If the intent is part of an ordered broadcast, then specifying
Stop Event will prevent it being passed to other listeners after this one.
Accessing Intent Data
When an intent triggers an Intent Received event, the resulting
task(s) which are executed have access to many details of the
intent via local variables (where relevant and present):
- %intent_data: the data
- %evtprm1: the action
- %evtprm2: the first category
- %evtprm3: the second category
- %evtprm4: the URI scheme
- %evtprm5: the MIME type
In addition, any extras attached to the intent can be
accessed under their name, with the following modifications to
make them valid variable names:
- all letters will be converted to lower-case, then
- names of length less than 3 will have var_ prefixed
- non-letter-or-digit characters will be converted to _, then
- names not starting with a letter will have a prefixed, then
- names not ending with a letter or digit will have a affixed
- if the result is the name of another extra, _dup will be affixed until that is no longer the case
For example, an extra with key %SOUND_ON will be available as %sound_on, and an
extra with key package.SOUND_ON!, will be available via the local variable %package_sound_on_a
The following extra types are presented in Tasker as local arrays:
String , Integer , ArrayList, ArrayList.
Example: a string array extra `named 'fruits' with values 'pear' and
'apple' will result in the local variables %fruits1 (=pear) and %fruits2 (=apple).