2012-08-13 60 views
0

在我的應用程序中,我必須使用Intent.setClassName或setComponent在另一個包中啓動一個活動。當我使用Intent.setClass時,沒有任何問題,如 Intent intent = new Intent(getApplicationContext(),org.iustb.knowledebase.animation.transparent.MainTransparentActivity.class); 在網絡上解決這個問題的建議是在AndroidManifest的目標活動中添加或android:exported =「true」,但它不起作用。 有沒有人可以幫助我?
我寫了下面的代碼:目標活動的權限拒絕:啓動意圖

Intent intent = new Intent(); 
intent.setClassName(cursor.getString(pIndex), cursor.getString(cIndex)); 
startActivity(intent); 

清單文件設置:

<activity android:name="org.iustb.knowledebase.animation.transparent.MainTransparentActivity" 
       android:exported="true"></activity> 
+1

你能不能從後'LogCat',該輸出將幫助我們給你更好的答案。 – 2012-08-13 08:28:02

回答

0

你確定了cursor返回正確的人的價值觀?

setClassName()的第一個參數應該是應用程序包名稱,而不是活動存在開始的包。

假設應用程序包是:com.testandroid,但你要開始從com.testandroid.other包的其他活動,那麼你的代碼應該是這樣的:

intent.setClassName("com.testandroid", "com.testandroid.other.OtherActivity"); 
+0

非常感謝你! – linHao 2012-08-13 15:12:30

相關問題