2

我是使用 SL4A 编写 Android python 脚本的新手,但熟悉 python。我的问题是,如何从另一个脚本以编程方式在 sl4a 脚本编辑器中打开一个脚本?我的英语不足以解释我的问题,所以我用伪代码显示它:

如果有人给我提示或帮助我解决这个问题,我将不胜感激。提前致谢 :)

from android import Android
droid = Android()

f = open("newScript.py", 'w')
f.write("bla bla bla")
f.close()
#now here is what I want it to do:
myintent = droid.makeIntent(WHAT, VARIABLES, SHOULD, I , USE, TO OPEN newScript.py?) 
#myintent should run the sl4a SCRIPT EDITOR
droid.startActivityIntent(myintent) `
4

1 回答 1

2

我不知道你是否还需要知道这一点,但以下将做你想做的事:

import android

droid = android.Android()

action = 'com.googlecode.android_scripting.action.EDIT_SCRIPT'
extras = {'com.googlecode.android_scripting.extra.SCRIPT_PATH':'/any/path/you/like.py'}

intent = droid.makeIntent(action, None, None, extras).result

droid.startActivityIntent(intent)
于 2012-12-11T01:48:20.130 回答