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

Nat*_*ons 5 python android sl4a

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

import android
droid = android.Android()
droid.launch('com.twitter.android')
Run Code Online (Sandbox Code Playgroud)

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

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

Tai*_*fun 8

你可以用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)