我想在我的项目中使用第三方Android项目,所以我将这个第三方项目的源导出到一个jar文件,然后将jar文件导入到我项目的Android Dependencies中。我在类里面添加了这段代码:
ComponentName componentName = new ComponentName(
"com.mobilevisualsearch",
"com.mobilevisualsearch.ActivityImageDetail");
String strImageSourcePath = "/storage/emulated/0/Camera/P40101-165253.jpg";
Bundle bd = new Bundle();
bd.putString("strPhotoFileFullName", strImageSourcePath);
Intent it = new Intent();
it.putExtras(bd);
it.setComponent(componentName);
startActivity(it);
com.mobilevisualsearch.ActivityImageDetail
是第三方项目的一个类。我的AndroidManifest.xml
被添加为
<activity
android:name="com.mobilevisualsearch.ActivityImageDetail"
android:configChanges="orientation"
android:screenOrientation="portrait" >
</activity>
这<activity>
在 <application>
下.当我运行我的应用程序时,出现错误。
这是 Logcat 日志:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.mobilevisualsearch/com.mobilevisualsearch.ActivityImageDetail}; have you declared this activity in your AndroidManifest.xml?
我该如何解决这个问题?
最佳答案
How can I fix this problem?
第 1 步:摆脱您的 ComponentName
和 setComponent()
调用
第 2 步:将您的 Intent
初始化替换为 Intent it = new Intent(this, ActivityImageDetail.class);
,添加 import
对于 ActivityImageDetail
如果需要的话
关于android - 您是否已在 AndroidManifest.xml 中声明此 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20869419/