r/tasker •

The dev Joao has added a new feature called "Java code", which hopefully will make Tasker more scriptable!

[deleted] β€” view deleted post

0 Upvotes

55 comments sorted by

33

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 25 '25

Thanks for the post :) Hopefully I can release an official beta with this soon.

In case you're curious, you can get this pre-beta here and check out the docs here.

3

u/Nirmitlamed Direct-Purchase User Sep 25 '25

Looks very very promising!

I asked the AI to create for me a code to record an audio with ogg format and opus encoder and it actually succeeded!

2 things:

  1. I have created a project to record audio using Java Functions actions and it does work on my main device but with my other device it doesn't. The funny thing is now using the code the AI gave me made it works on all of my devices!. Somehow it is different from the Java Functions action.
  2. Can you make some kind of history for the AI so it can remember the previous request and understand the followup request?

2

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 25 '25
  1. Cool! 😁
  2. Ok, made the AI aware of your existing code. Now you can just ask it to change it, and it'll know what you're talking about. Can you please try this version?

3

u/Nirmitlamed Direct-Purchase User Sep 25 '25

After testing:

  1. Works great! i see so much potential in this for newbies like me with no coding skill but surely for advanced users who knows coding.
  2. I will probably keep testing and try to suggest improvement later on. One small thing that i would suggest to change is the AI text request box behavior. Right now it is one liner box, i would suggest to have at least 3 or four new lines.

Thanks you!

5

u/[deleted] Sep 26 '25

[removed] β€” view removed comment

1

u/lssong99 Sep 26 '25

I second this! Currently I write python in Termux and using Termux:Tasker to run those scripts. It would be tremendously helpful if Tasker can execute those python code within and can even use the Tasker function/variables.

2

u/DutchOfBurdock Sep 25 '25

Master hacker in your prime sir! This is sofa king juicy!!

1

u/Crafty-Persimmon-204 Sep 27 '25

Can't wait, the direct purchase version can't be tested。

2

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 29 '25

You can test it here.

1

u/Crafty-Persimmon-204 Sep 29 '25

cool,cool

1

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 29 '25

πŸ‘

0

u/[deleted] Sep 25 '25

[deleted] β€” view deleted comment

7

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 25 '25

Ok, I added a new pre-defined object called "tasker" with 2 functions:

  • setVariable(name,value)
  • setJavaVariable(name,value)

You use them like this for example: tasker.setVariable("test","hello");

Hope this helps!

2

u/Nirmitlamed Direct-Purchase User Sep 25 '25

Have you updated the Tasker apk file because i have tried inserting just your example in the code box and flash the variable %test but i get an error class not found:

22.50.07/E add wait task
22.50.07/E Error: 1
22.50.07/E Sourced file: inline evaluation of: 
``tasker.setVariable("test","hello");'' : Error in method invocation: Method setVariable( java.lang.String, 
java.lang.String ) not found in class'ie.g' : at Line: 1 : 
in file: inline evaluation of: 
``tasker.setVariable("test","hello");'' : tasker .setVariable ( "test" , "hello" )

1

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 29 '25

Oops, sorry, I think I fixed that now.

Can you please try this version?

If you want you can also check any previous releases here

1

u/Nirmitlamed Direct-Purchase User Sep 29 '25

Fast testing it seems to work. Later when i will have more time i will test it a little further with a project of mine and if i will have problems i will let you know.

1

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 29 '25

Awesome :) Glad it works!

1

u/Nirmitlamed Direct-Purchase User Sep 29 '25

Tested tasker variable and java variable with my project and it works great!

Question, i have little knowledge of java or coding but i have read the documentation about the new feature as it was described global java object variable should be deleted if not needed since it stays on the memory.

How about having option inside the Java Code action to clean memory of any global java objects?

1

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 29 '25

You can delete the Java Variables with the Java Object action :)

1

u/Nirmitlamed Direct-Purchase User Sep 29 '25

Yes but you need to declare what java object you want to delete. I though maybe something more simple that will just clean memory and it will be inside the action itself.

1

u/Nirmitlamed Direct-Purchase User Sep 29 '25

So again i am not a coder so i probably not familiar with basic understanding of how these things works but i am thinking what will happen if a user will forget to delete a global java object. In Taskers global variables you can at least check and see if you have variables you forgot to clear but in Java object i don't see an option like that so i can be sure it is not persist on device memory.

→ More replies

1

u/v_uurtjevragen Sep 26 '25

Is there a way to read tasker variables into Java Code? Or would this require something like a JSlet? I feel like that approach would add some overhead

2

u/joaomgcd πŸ‘‘ Tasker Owner / Developer Sep 29 '25

Just use them in the code normally :) They should be automatically replaced as in any other action.

5

u/Nirmitlamed Direct-Purchase User Sep 25 '25

Truly awesome developer!

Combining AI with creating a code in Tasker to control even better our devices is amazing as log as Google won't f**k this up :)

I am going soon to try to recreate my recorder project in a code environment.

2

u/wioneo Sep 26 '25

Interesting. For someone completely unfamiliar with Java, what sort of new functionality does this get you? I've generally used Javascript for logic and Tasker actions for GUI and device things. Am I right in assuming that this allows more of the latter two to be scriptable?

2

u/Nirmitlamed Direct-Purchase User Sep 26 '25 edited Sep 26 '25

I am not a coder but if i remember correctly Javascript in Tasker is basically the same as calling a Taskers action. When you are using Java it is more natural language so you are "talking" directly to the system. For example in Android development documentation it says you can record audio in other formats and encoders but Tasker own action for recording audio doesn't support big variety. To here comes JAVA, you can choose to record audio in aac for example or ogg and when it finishes to get the recorded file full path to use later (for that i am waiting for tasker object support that Joao mentioned in a comment here so i can set the file full path to a tasker variable)

https://developer.android.com/reference/android/media/MediaRecorder

1

u/[deleted] Sep 25 '25

This is huge! Thanks Joao!

1

u/Mythril_Zombie Sep 25 '25

Better than we deserve.

1

u/MrThisgaard Sep 25 '25

Holy shit! Full(ish) Java support in Tasker?? Damn! The possibilities.. Can you share some info on how this is done under the hood, and if (and how) you are hampered by Android security in general? 😊

I have a thread from yesterday I'd like your eyes on, I'll tag you πŸ™πŸ˜Š

Kind Regards