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