Playing with Intent URI

sjmd

New member
I'm not sure it does work both ways.
Ideally, I would like to do it easily. I can tap on a KWGT widget which will then launch a shortcut that fires a MD macro. This macro can be used to send a variable back to KWGT but that is not what I want to do.
I would like to trigger a shortcut but send additional data at the same time. I think the KWGT send variable only works for data going strictly from MD/Tasker to KWGT only.
 

Dm114

Well-known member
This also works in reverse.

Macrodroid -> KWGT

KWGT -> Macrodroid

Create a macro when launching define variable with variable data defined by the user then when clicking like in my video it asks you for the variable data
As @sjmd said, I've been using KWGT for years, too, and never found the way to pass data from KWGT towards MD...
 

Winny57

Member
Watch my video!
when I click on my macrodroid widget asks for the data to put in the variable then sends a notification.

If you specify which data you want to send to macrodroid this could help even more, I have a setting so that macrodroid requests the data manually but it could be automatically.
 

Dimlos

Well-known member
I think you can open the URL with touch action and send the parameters via Webhook or HTTP Server Response.
 

sjmd

New member
Well it looks like I can now pass data from KWGT to MD via broadcast intent. It's not as pretty as I would have hoped but it seems to work albeit after a fashion. It ended up being a mix of so many different ideas that in the end it was found by accident. Perhaps the answer was already out there but it just took longer for it to start working with my setup.

In MD I have a macro which is triggered by a receive intent. The action at the top is just one word - "triggertask". It doesn't have to be more than one word and can be anything you like really. That's how I've always set them up and they work. There are two string "extras" that are setup in the receive intent, namely 'xfromapp' and 'xindata', the x prefixes are just to remind me that they are the extras. They are both saved to local variables with the same name minus the x prefix. Anything really.

It's a good idea to setup another separate macro that sends an intent out to test the first macro that receives them. When you setup the send intent, set the target to 'broadcast', the action to 'triggertask' (or whatever you want = same as the receive intent action) and the package to 'com.arlosoft.macrodroid'. Don't forget to setup the extras at the bottom too, in my case there are two and they are of type string and are called 'xfromapp' and 'xindata'.

The last thing in MD is to create two local variables inside the receive intent macro. This is where the received data from KWGT will be held. I just called them the same as the extras above but without the x prefixes. Whatever.

In KWGT/KWLP a new widget/shape is created. Firstly, in the root of the widget add a new flow. Doesn't matter what name it is. Flow000 is fine. Set the trigger to 'Manual' and then add a new formula action.

Now for the bit which still puzzles me.
Set the formula to the following...

$sh("am broadcast --user 0 -a triggertask -e xfromapp KWGT -e xindata smelly")$

It basically tells KWGT to run a shell command (application manager I think 🤔) and gives it certain parameters. Our -a or action 'triggertask' is there. The two separate -e or extras parameters are there. The two strings I passed were "KWGT" to xfromapp and "smelly" to xindata. They are just strings. They can hold any text you like.

What I don't understand yet is what the "--user 0" part does. I also don't know why I don't have to specify the com.arlosoft.macrodroid as a package anywhere. In truth it used to be there when I was playing around with it and it was only as soon as I had deleted it that it fired the macro to my amazement.

What's also annoying is that it doesn't always fire when the Kustom widget or shape is pressed. What I mean to say is it that after about a minute it works again. My guess at the moment is that I might need to add a flag in the command line that clears something immediately ready for the next press or something.

Either way, it's a step in the right direction. Just needs refining now to make it have a better response.
 

sjmd

New member
Well, having used this for a day it is not perfect at all. The intent doesn't seem to want to fire on repeated taps of the widget. About a minute or so later it will fire again when tapped. Quite random.

Also, when in the Kustom widget editor and just selecting the widget to edit, the intent will fire which is not much cop.

I don't seem to be able to feed kustom variables into the extras either.

Ho hum.
 
Last edited:

sjmd

New member
At the moment it's just simple text, maybe just a word. I only want to have one macro but be able to send different text to it from KWGT. I'm not quite sure how that's done from your video.
 

Winny57

Member
When I click on my KWGT widget it triggers a macro which asks the user for the variable data then simply sends it to the general variable
 

sjmd

New member
That's one way I agree, but I didn't want any user interaction. I would have the extra data already to send along to the macro I was calling or working with.
 

sjmd

New member
It's a little bit like a normal function in most programming languages. You would call the function and pass data to it at the same time.

As far as just simply calling a function, that is the same as calling a macro. We can just launch a shortcut from KWGT and just run the right macro, but we can't send any data to the macro at the same time using that method.
 

Winny57

Member
It's a little bit like a normal function in most programming languages. You would call the function and pass data to it at the same time.

As far as just simply calling a function, that is the same as calling a macro. We can just launch a shortcut from KWGT and just run the right macro, but we can't send any data to the macro at the same time using that method.
You can send data but manually like in my video



either automatically but you need to know what data
 
Top