繁体   English   中英

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

[英]Launch android app from SL4A script?

我在 /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'
                   )

请参阅API 参考中的语法:

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM