是否可以将 SL4A 脚本存储在本地数据库中并从 java Activity.class 中运行它们?

发布于 2024-12-18 00:07:47 字数 265 浏览 2 评论 0原文

我正在考虑一个想法,将 SL4A 代码脚本片段存储在“常规”java Android 应用程序的本地数据库中。这个想法是在运行时从 Activity 类中检索这些代码片段并执行它们。

尽管我用了最好的谷歌搜索,但我还是找不到任何例子,这对我来说是一个坏兆头。有很多关于如何运行 SL4A 脚本的示例,但似乎没有一个示例显示如何将脚本作为字符串(或流)对象检索,然后从活动中执行脚本。

我确实找到了一个接近我想要的示例,但它似乎没有提供执行多行脚本的能力,并且需要 root 访问权限。

I'm toying around with an idea in which I store SL4A code script snippets inside a db local to a "regular" java Android app. The idea is to retrieve those code snippets from within an Activity class at run time and execute them.

I haven't been able to find any examples despite my best google-fu, which strikes me as a bad sign. Plenty of examples on how to run SL4A scripts, but none that seem to show an example of how to retrieve a script as a String(or stream) object and then execute the script from within an Activity.

I did find one example that was close to what I want, but it didn't seem to offer the ability to execute multiple lines of script and it required root access.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月如刀 2024-12-25 00:07:47

您可以从数据库中检索脚本内容,然后将其写入文件,最后调用 SL4A 来运行它?一个用 Python 语言编写的例子:

// get script
script = db.fetchScript(ID)
// write script to file
path = "/mnt/sdcard/myapp/scripts/temp.py"
file = open(path,Mode.WRITE)
file.write(script)
file.close()
// execute
intent = makeIntent(...)
startActivity(intent)

祝你好运!

You could retrieve the script contents from your DB and then write it to a file, finally calling for SL4A to run it? An example in a made up / Python-y language:

// get script
script = db.fetchScript(ID)
// write script to file
path = "/mnt/sdcard/myapp/scripts/temp.py"
file = open(path,Mode.WRITE)
file.write(script)
file.close()
// execute
intent = makeIntent(...)
startActivity(intent)

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文