从启动脚本SL4A Android应用? [英] Launch android app from SL4A script?

查看:521
本文介绍了从启动脚本SL4A Android应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/sdcard/sl4a/scripts/twitter.py以下

I have the following in /sdcard/sl4a/scripts/twitter.py

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

如果我在控制台或后台运行它,它马上用code 1退出和日志文件是空的。

And if I run it in the console or the background, it immediately exits with code 1, and the log file is empty.

如果有其他的方法,从某种脚本启动应用程序,我很开放的建议。我知道塔斯克的,但我宁愿写的文字脚本不是使用向导。

If there are other ways to launch applications from some sort of script, I'm open to suggestions. I know of Tasker, but I'd rather write text scripts than use a wizard.

推荐答案

您可以使用 startActivity 为:结果

you can use startActivity for that:

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

看语法在参考


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)

这篇关于从启动脚本SL4A Android应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆