2011-05-18 45 views
0

我正嘗試使用意圖啓動我的應用程序內的ApiDemos應用程序。 我創建了以下意圖:如何在Android應用程序中啓動ApiDemos

Intent i = new Intent(); 
i.setAction("android.intent.action.MAIN"); 
i.addCategory("android.intent.category.LAUNCHER"); 
i.setComponent(ComponentName.unflattenFromString("com.example.android.apis/com.example.android.apis.ApiDemos")); 
i.addCategory(Intent.CATEGORY_LAUNCHER); 

當我的代碼調用這個意圖抓到一個SecurityException並給出了下面的詳細信息:從com.example.android.apis請求碼(UID爲10035)中運行process com.TICE.customtabs(with uid 10036)

有沒有什麼辦法讓我從我自己的應用程序中調用ApiDemos應用程序? 我必須導入所有的ApiDemo代碼並將其編譯到我的應用程序中嗎?

回答

0

你不需要類別LAUNCHER。這已經足夠了:

Intent i = new Intent(Intent.ACTION_MAIN); 
i.setClassName("com.example.android.apis", "com.example.android.apis.ApiDemos"); 
startActivity(i); 
+0

我意識到我真正的問題不是意圖,而是我的應用程序如何處理需要在單獨進程中運行的啓動活動的問題。 – ericharlow 2011-05-18 19:18:58

相關問題