Get Task name that fired plugin

49 views
Skip to first unread message

georgero...@gmail.com

unread,
Feb 23, 2015, 9:41:59 PM2/23/15
to task...@googlegroups.com
I've implemented a Java Tasker plugin for my app. I'm trying to get the name of the task that fired my plugin and I'm having trouble:

1. I can't seem to get any Tasker variables to be replaced. I've added the code below to EditActivity
if (TaskerPlugin.Setting.hostSupportsOnFireVariableReplacement(this))
TaskerPlugin.Setting.setVariableReplaceKeys(localeBundle,
new String[] { PluginBundleManager.BUNDLE_EXTRA_STRING_ACTION });

2. In my PluginBundleManager:
        result.putString(BUNDLE_EXTRA_STRING_ACTION, message 
         + "; Location=%LOC, caller=%caller");

as an attempt to get a variable replaced.

3. I don't know what the Tasker variable name would be for the Task name.

Can someone help me?
George

Pent

unread,
Feb 23, 2015, 11:21:35 PM2/23/15
to task...@googlegroups.com, georgero...@gmail.com
First can I please ask why you want the task name ?

Pent

p.s. thanks for reposting

George Brown

unread,
Feb 27, 2015, 10:36:57 PM2/27/15
to Pent, task...@googlegroups.com

I have a plugin that can be called from several tasks. I want to know which of those tasks fired.

BTW, I figured out that I was calling setVariableReplaceKeys in EditActivity.on create and not finish. It now works. But interestingly, it replaces Tasker variables like %TRUN and %PENABLED but not %PACTIVE. Is this a bug?

George

Pent

unread,
Mar 2, 2015, 2:23:41 AM3/2/15
to task...@googlegroups.com, crafty...@gmail.com, georgero...@gmail.com

BTW, I figured out that I was calling setVariableReplaceKeys in EditActivity.on create and not finish. It now works. But interestingly, it replaces Tasker variables like %TRUN and %PENABLED but not %PACTIVE. Is this a bug?


%PACTIVE is probabaly not set at the time it was replaced.

Pent

George Brown

unread,
Mar 2, 2015, 6:55:41 PM3/2/15
to task...@googlegroups.com, Pent

Where/when does %PACTIVE get set? %PENABLED is set. To test, I created a pop up and printed both variables. %PENABLED is replaced correctly, %PACTIVE is not.

George

Pent

unread,
Mar 6, 2015, 2:42:53 AM3/6/15
to task...@googlegroups.com, crafty...@gmail.com, georgero...@gmail.com


Where/when does %PACTIVE get set?


See the Variables section of the Userguide.

Pent

George Brown

unread,
Mar 6, 2015, 7:04:30 AM3/6/15
to task...@googlegroups.com, Pent

From the User's Guide.

Profiles Active (dynamic) 
%PACTIVE
A comma-separated list of the currently active, named profiles in activation order. Duplicate names will appear on the list only once. The list always starts and ends with a comma to make matching easier, if it's not empty.

This description for PACTIVE (which isn't replaced) looks very similar to PENABLED (which is replaced). Only the word "enabled" and "active" are different in the two descriptions. What am I missing by just bring pointed the Variables section of the User's Guide?

George

Berna Bap

unread,
Mar 6, 2015, 7:27:05 AM3/6/15
to task...@googlegroups.com
George, I never used this variables but I think Pent is trying to show you that:

PACTIVE = List of active profiles, if there is no active profiles while you read this variable the list will be empty.

PENABLED = List of enabled profiles, any profile that you have done and it is enabled will be listed here.
--
You received this message because you are subscribed to the Google Groups "Tasker - Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taskerdev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

George Brown

unread,
Mar 6, 2015, 7:40:51 AM3/6/15
to task...@googlegroups.com, task...@googlegroups.com

%PACTIVE is not replaced at all. I would have expected to have an empty list returned (per the documentation, "the list starts and ends with a comma to make parsing easier") as opposed to the literal string "%PACTIVE". That indicates to me that the variable never gets replaced as opposed to no active profiles. Do I need to check for the variable name as a value to indicate that the list is empty and that there are no active profiles?

That being said, wouldn't there be at least one active profile at the time my task was fired - namely the one that actually caused my task to fire? In my case, I have a Geofence Inside event.

George

Pent

unread,
Mar 6, 2015, 9:04:54 AM3/6/15
to task...@googlegroups.com, georgero...@gmail.com
See 'Uninitialized Variables' in the Variables section of the Userguide.

Pent

George Brown

unread,
Mar 6, 2015, 3:41:07 PM3/6/15
to Pent, task...@googlegroups.com

Per your response (read "Uninitialized Variables" in the User's Guide) and my response below, am I to conclude that this is an error in the documentation quoted below stating that Tasker supports the global variable %PACTIVE when it really doesn't, or this is a bug in Tasker and is is not replacing the global variable when it should?

George
--------------

%PACTIVE is not replaced at all. I would have expected to have an empty list returned (per the documentation, "the list starts and ends with a comma to make parsing easier") as opposed to the literal string "%PACTIVE". That indicates to me that the variable never gets replaced as opposed to no active profiles. Do I need to check for the variable name as a value to indicate that the list is empty and that there are no active profiles?

That being said, wouldn't there be at least one active profile at the time my task was fired - namely the one that actually caused my task to fire? In my case, I have a Geofence Inside event.

George

Berna Bap

unread,
Mar 6, 2015, 10:13:28 PM3/6/15
to task...@googlegroups.com
You forgot to quote the "IF, it's not empty"! That means if it is empty will not starts and ends with a comma, when reading this variable with no profiles active you get "%PACTIVE" as value. I have tested here and it works like described in documentation.

Pent

unread,
Mar 9, 2015, 2:46:37 AM3/9/15
to task...@googlegroups.com


You forgot to quote the "IF, it's not empty"! That means if it is empty will not starts and ends with a comma, when reading this variable with no profiles active you get "%PACTIVE" as value. I have tested here and it works like described in documentation.

Also %PACTIVE only includes NAMED profiles.

Pent
Reply all
Reply to author
Forward
0 new messages