从SL4A脚本启动一个SL4A脚本 [英] Launch an SL4A script from an SL4A script

查看:536
本文介绍了从SL4A脚本启动一个SL4A脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个不同的SL4A脚本启动后台SL4A脚本(在远程设备上)。我可以从一个终端运行像这样启动脚本:

  $日凌晨开始-a \
com.google code.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT -n \
com.google code.android_scripting / .activity.ScriptingLayerServiceLauncher -e \
com.google code.android_scripting.extra.SCRIPT_PATH /sdcard/sl4a/scripts/main.py
 

我不能把它理解Python中的 startActivity 电话。

这个问题的答案上打开一个不同的问题一个Twitter客户端很好地工作,但我不知道如何来扩展code。例如,你会怎么添加脚本路径,你会在哪里放线 com.google code.android_scripting / .activity.ScriptingLayerServiceLauncher

解决方案

许多,许多失败的尝试后,我现在有这方面的工作在Ruby中 - 我有一个更简单的时间产生的JSON额外这种方式比在Python

重要!   在命令行版本,你的com.google code.android_scripting / .activity.ScriptingLayerServiceLauncher

打电话

在脚本中,这被称为com.google code.android_scripting.activity.ScriptingLayerServiceLauncher,没有斜线。离开的斜线崩溃SL4A。

[code]

要求'机器人' 要求JSON /纯

D = Android.new

脚本='/ SD卡/ SL4A /脚本/ YOUR_SCRIPT

数据= {com.google code.android_scripting.extra.SCRIPT_PATH=>脚本}

演员= JSON.generate(数据)

d.startActivity('com.google$c$c.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT','','',data,true,'com.google$c$c.android_scripting','com.google$c$c.android_scripting.activity.ScriptingLayerServiceLauncher')

[/ code]

我希望这有助于!

I would like to start a background SL4A script (on a remote device) from within a different SL4A script. I can launch a script from a terminal by running something like this:

$ am start -a \
com.googlecode.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT -n \
com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher -e \
com.googlecode.android_scripting.extra.SCRIPT_PATH /sdcard/sl4a/scripts/main.py

I can't translate this into a startActivity call in Python.

The answer to a different question on opening a Twitter client works nicely, but I don't know how to extend that code. For example, how would you add a script path, and where would you put the line com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher?

解决方案

After many, many failed attempts, I now have this working in Ruby - I had an easier time generating the JSON extras this way than in Python.

Important! In the command-line version, you call on "com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher"

From within a script, this is called as "com.googlecode.android_scripting.activity.ScriptingLayerServiceLauncher", without the slash. Leaving in the slash crashes sl4a.

[code]

require 'android' require 'json/pure'

d=Android.new

script = '/sdcard/sl4a/scripts/YOUR_SCRIPT'

data = {"com.googlecode.android_scripting.extra.SCRIPT_PATH"=>script}

extras = JSON.generate(data)

d.startActivity('com.googlecode.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT','','',data,true,'com.googlecode.android_scripting','com.googlecode.android_scripting.activity.ScriptingLayerServiceLauncher')

[/code]

I hope this helps!

这篇关于从SL4A脚本启动一个SL4A脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆