2012-08-13 59 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

相关问题