Hi DS, I'm scratching my head a little trying to fathom sending and receiving simple text to and from a macro in Macrodroid.
I've looked carefully at the send and receive intents examples together with the send file example which also uses intents. The latter is interesting as there is a simple text intent going on there which looks easy enough.
I gather I have to change the "packageName" to the com.arlosoft.macrodroid. I've nulled the category as I wish the action to be explicitly for a a macro, so no broadcasting.
Does the action name have to stay exactly the same together with the extra name (TEXT) or can they be literally anything?
I'm struggling to receive the intent in macrodroid as I'm not precisely sure what the naming of the action and extra fields need to be, single names or the OO expression names as seen in the droidscript example.
What would macrodroids send intent have to look like to get text through to droidscript too?
Any help will be appreciated.
Code as follows:-
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" )
//Create a button 1/3 of screen width and 1/10 screen height.
btn = app.CreateButton( "Send Intent", 0.3, 0.1 )
btn.SetOnTouch( btnTxt_OnTouch )
lay.AddChild( btn )
//Add layout to app.
app.AddLayout( lay )
}
//Send text to Macrodroid.
function btnTxt_OnTouch()
{
var textData = "The cat sat on the mat";
var packageName = "com.arlosoft.macrodroid"; // Changed for Macrodroid
var className = null;
var action = "android.intent.action.SEND";
var category = null; // "android.intent.category.DEFAULT"; nulled so as not to broadcast to share sheet
var uri = null;
var type = "text/plain";
var extras = [
{name:"android.intent.extra.TEXT", type:"string", value:textData},
];
extras = JSON.stringify( extras )
app.SendIntent(packageName, className, action, category, uri, type, extras)
}