android - 从 SL4A 脚本启动 android 应用程序?

标签 android python sl4a

我在/sdcard/sl4a/scripts/twitter.py 中有以下内容

import android
droid = android.Android()
droid.launch('com.twitter.android')

如果我在控制台或后台运行它,它会立即以代码 1 退出,并且日志文件为空。

如果有其他方法可以从某种脚本启动应用程序,我愿意接受建议。我知道 Tasker,但我宁愿编写文本脚本也不愿使用向导。

最佳答案

您可以为此使用 startActivity:

import android
droid = android.Android()
droid.startActivity('android.intent.action.MAIN', 
                    None, None, None, False, 
                    'com.twitter.android', 
                    'com.twitter.android.StartActivity'
                   )

参见语法 in the API Reference :

startActivity(
   String action,
   String uri[optional],
   String type[optional]: MIME type/subtype of the URI,
   JSONObject extras[optional]: a Map of extras to add to the Intent,
   Boolean wait[optional]: block until the user exits the started activity,
   String packagename[optional]: name of package. If used, requires classname to be useful,
   String classname[optional]: name of class. If used, requires packagename to be useful)

关于android - 从 SL4A 脚本启动 android 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12737150/

相关文章:

android - YouTube播放器旋转时停止

java - 如何强制Android重新读取GPS位置?

android - 您最喜欢在 Android 手机上使用的代码编辑器是什么?

python - 打开两个文件的最佳方式

android - 我想在 z 轴上旋转 imageview

javascript - Android webview位置检测javascript

python - Pygame 矩形类

Python 模式

python - 带有 'parser.compile_filter(tokens[2])' 的 Django 自定义模板标签不起作用