2012-10-04 38 views
4

我已經中/sdcard/sl4a/scripts/twitter.py從SL4A腳本啓動android應用程序?

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

下如果我在控制檯或後臺運行它,它會立即與代碼1退出,日誌文件是空的。

如果還有其他方法可以從某種腳本啓動應用程序,我願意提供建議。我知道Tasker,但我寧願編寫文本腳本,也不願意使用嚮導。

+0

當然,當我問這個,我嘗試其他的作品。我可以從Tasker調用Javascript文件,它提供了一個「正常工作」的loadApp()函數。如果您對答案滿意,請將其打開JIC –

+0

,請將其標記爲已回答。謝謝。 – Taifun

回答

8

可以使用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)
+0

如果我想打開例如Twitter中的特定標籤,該怎麼辦?或者不是在視頻播放器應用程序中打開視頻? – aesede

+0

1.我認爲你不能這樣做,2.試試這個:'droid.startActivity('android.intent.action.VIEW','vnd.youtube:3nH_T9fLd_Q',None,None,False,None,None )' – Taifun

+0

好的,這很好,你的例子與youtube一起工作。但你如何得到這個部分:''vnd.youtube:vid_ID''?它在哪裏記錄?我很難找到這樣的信息。我想做一些類似於Android的VLC,或者MX Player。謝謝! – aesede