【问题标题】:How to open a script in sl4a script editor, programmatically from another script?如何在 sl4a 脚本编辑器中以编程方式从另一个脚本打开脚本?
【发布时间】:2012-03-01 03:22:58
【问题描述】:

我是使用 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) `

【问题讨论】:

    标签: android python wsh sl4a


    【解决方案1】:

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

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-21
      • 1970-01-01
      • 1970-01-01
      • 2018-10-11
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多