Hi.
I´m thinking about migrating from Tasker to DroidScript, but first I need to make sure I can send variables and execute LL scripts from DroidScript using broadcast intents. What would be the list of parameters I need to send?. For example, I’ve managed to send a variable from DroidScript to KLWP using this:
KUSTOM_ACTION = “org.kustom.action.SEND_VAR”;
KUSTOM_ACTION_EXT_NAME = “org.kustom.action.EXT_NAME”;
KUSTOM_ACTION_VAR_NAME = “org.kustom.action.VAR_NAME”;
KUSTOM_ACTION_VAR_VALUE = “org.kustom.action.VAR_VALUE”;
KUSTOM_ACTION_VAR_NAME_ARRAY = “org.kustom.action.VAR_NAME_ARRAY”;
KUSTOM_ACTION_VAR_VALUE_ARRAY = “org.kustom.action.VAR_VALUE_ARRAY”;
var extras = [
{name:KUSTOM_ACTION_EXT_NAME, type:”string”, value: “droidscript”},
{name:KUSTOM_ACTION_VAR_NAME, type:”string”, value: “ds_var”},
{name:KUSTOM_ACTION_VAR_VALUE, type:”string”, value: “test variable from droidscript”}
];
extras = JSON.stringify( extras );
app.BroadcastIntent(KUSTOM_ACTION,null,null,null,extras);
Is it possible to do something similar for Lightning Launcher?
]]>
< ![CDATA[
I´m almost there, mostly need to fill the part where I create the variables and execute a script. This is where I’m now (code to receive a custom Broadcast):
// modified from: lightninglauncher.com – script_music_metadata [Lightning Launcher]
var intents=[“com.smartphoneremote.androidscriptfree.ACTION_ENVIAR_VARIABLE”];
LL.bindClass(“android.content.IntentFilter”);
LL.bindClass(“android.os.Bundle”);
LL.bindClass(“android.content.BroadcastReceiver”);
LL.bindClass(“android.graphics.Bitmap”);
LL.bindClass(“java.io.FileOutputStream”);
var receiver=new JavaAdapter(BroadcastReceiver,{
onReceive:function(c,i){
var e=i.getExtras();
var v=LL.getVariables().edit();
if(e.containsKey(“droidscript.ACTION”)){
if (e.getString(“droidscript.ACTION”) == “ENVIAR_VARIABLE”)
{
Android.makeNewToast(e.getString(“VAR_NAME”), true).show();
Android.makeNewToast(e.getString(“VAR_VALUE”), true).show();
} else if (e.getString(“droidscript.ACTION”) == “EJECUTAR_SCRIPT”)
{
Android.makeNewToast(e.getString(“NOMBRE_SCRIPT”), true).show();
}
}
else { Android.makeNewToast(“No contiene VAR_VALUE”, true).show(); }
v.commit();
}
});
var f = new IntentFilter();
for(var i=0;i
f.addAction(intents[i]);
LL.getContext().registerReceiver(receiver,f);
But there goes another question. While I’m testing, each time I execute the script then a new receiver is created, so if I send an intent after two executions from this script then the test toasts show two times (four in total for ENVIAR_VARIABLE), and so on. Is there any way to get a list of registered intent reciver to decide if I add a new one? or how could I unregister all the receivers, or at least restart Lightning Launcher without restarting the whole smartphone?
]]>