4

sl4a 的所有脚本都在 /sdcard/sl4a/scripts 下

是否可以运行位于其他地方的脚本:

例如来自 /sdcard/dropbox/pyscripts [眨眼眨眼]

4

5 回答 5

5

这有点老了,但我来这里是为了寻找这个问题的答案,我找到了一个,所以我想我应该和其他人分享它,谷歌搜索和我一样的东西。

当您发出 Android Intent 以在 SL4A 中运行脚本时,您可以指定文件系统上的任何脚本。你可以编写一个脚本来发出这个意图,(或者一个应用程序,如果你喜欢的话)。这是 Python 中的一个示例:

import android

droid = android.Android()

activity = 'com.googlecode.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT'
extras = {}
extras['com.googlecode.android_scripting.extra.SCRIPT_PATH'] = '/any/script/you/like.py'

packagename =  'com.googlecode.android_scripting'
classname = 'com.googlecode.android_scripting.activity.ScriptingLayerServiceLauncher'

intent = droid.makeIntent(activity, None, None, extras, None, packagename, classname).result

droid.startActivityIntent(intent)

我已经考虑到了这一点,所以(我希望)更容易看到发生了什么。如果您从脚本调用 getIntent(),它将向您显示调用它的意图的剖析。我就是这么想出来的。

于 2012-12-08T18:28:21.580 回答
1

我认为目前的答案是否定的。

该应用程序没有设置该路径的选项。我唯一的另一个想法是创建一个从保管箱文件夹到脚本目录的符号链接。但这也有一些主要问题,最大的问题是大多数 SD 卡都是用 FAT32 格式化的,它根本不支持符号链接。如果您有不同的文件系统,则可以尝试该路径。不确定是否需要root - 我想在sdcard上写应该不需要。也不确定应用程序是否正确处理链接,但理论上整个链接应该对其不可见,并作为普通文件夹处理。

于 2011-11-20T02:53:47.650 回答
1

回答一个老问题.. 但我找到了一种方法来使用 Dropsync(免费应用程序),它可以将 SD 卡上的任何文件夹与特定的 DropBox 文件夹同步。它可以双向同步,但也有许多其他同步选项。

Dropsync: https ://play.google.com/store/apps/details?id=com.ttxapps.dropsync&hl=en

于 2013-03-13T00:20:32.800 回答
0

试试 Touchqode 应用程序。它可以执行 sl4a 脚本。

于 2012-06-27T22:32:55.723 回答
0
<intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <data android:scheme="file" />
                 <data android:host="*" />
                 <data android:pathPattern=".*\\.py"
                     android:mimeType="*/*" />
</intent-filter>

将其添加到主要活动意图过滤器下的应用清单

        String path = getIntent().getDataString();
        if(path!=null){         //this happens if you open the app without clicking on any .py file
            path=path.substring(7);
            Intent intent=new Intent();                     
            intent.setComponent(new ComponentName("com.googlecode.android_scripting","com.googlecode.android_scripting.activity.ScriptingLayerServiceLauncher"));   
            intent.putExtra("com.googlecode.android_scripting.extra.SCRIPT_PATH",path);
            intent.setAction("com.googlecode.android_scripting.action.LAUNCH_FOREGROUND_SCRIPT");
            startActivity(intent);
            System.exit(0);

       }

将此代码添加到主活动

现在您有了一个闪亮的应用程序,只要您单击任何扩展名为 .py 的文件,就会启动该应用程序。要使用更多脚本类型,请添加更多 pathPatterns。此外,您现在可以编写自己的应用程序来编辑 .py 文件/搜索任何位置的所有脚本,然后在 sl4a 中运行它们。Play 商店中还有一个名为 sl4a 脚本启动器的应用程序

于 2014-10-04T11:29:01.310 回答