Hello,
Thank you for the nice application.
How to pass a variable to "SL4A"?
This code does not work.
Automagic Action
ACTION TYPE = Plugin (Experimental)
PLUGIN = SL4A
OVERRIDE SETTINGS
//putBoolean("com.googlecode.android_scripting.extra.EXTRA_LAUNCH_IN_BACKGROUND", true);
//putString("com.googlecode.android_scripting.extra.SCRIPT_PATH", "/mnt/sdcard/sl4a/scripts/test.py");
putString("TEST", "TEST Message!");
SL4A PythonScript (/mnt/sdcard/sl4a/scripts/test.py)
import sys
import android
droid = android.Android()
try:
teststr = droid.getIntent().result[u'extras'][u'TEST']
droid.makeToast(teststr)
except:
droid.makeToast('Error') <-----
sys.exit(1)
----
Best Regards
How to pass a variable to "SL4A"?
Moderator: Martin
Re: How to pass a variable to "SL4A"?
Hi,
According to the source of the SL4A plugin, the plugin component receives the intent and builds a completely new intent to start the script containing only the path of the script and the background property, all other extras are discarded.
In this case you have to bypass the plugin component and start the script directly yourself using an action Start Activity in Automagic:
Action:
com.googlecode.android_scripting.action.LAUNCH_FOREGROUND_SCRIPT
or
com.googlecode.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT
Explicit Component: checked
Package Name:
com.googlecode.android_scripting
Class Name:
com.googlecode.android_scripting.activity.ScriptingLayerServiceLauncher
Extras:
putString("com.googlecode.android_scripting.extra.SCRIPT_PATH", "/mnt/sdcard/sl4a/scripts/test.py");
putString("TEST", "TEST Message!");
Alternatively you could use the clipboard or a temporary file to pass data to your script.
Regards,
Martin
According to the source of the SL4A plugin, the plugin component receives the intent and builds a completely new intent to start the script containing only the path of the script and the background property, all other extras are discarded.
In this case you have to bypass the plugin component and start the script directly yourself using an action Start Activity in Automagic:
Action:
com.googlecode.android_scripting.action.LAUNCH_FOREGROUND_SCRIPT
or
com.googlecode.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT
Explicit Component: checked
Package Name:
com.googlecode.android_scripting
Class Name:
com.googlecode.android_scripting.activity.ScriptingLayerServiceLauncher
Extras:
putString("com.googlecode.android_scripting.extra.SCRIPT_PATH", "/mnt/sdcard/sl4a/scripts/test.py");
putString("TEST", "TEST Message!");
Alternatively you could use the clipboard or a temporary file to pass data to your script.
Regards,
Martin
Re: How to pass a variable to "SL4A"?
Thanks for the quick support Martin.
Worked perfectly thanks !
Worked perfectly thanks !