android - 您是否已在 AndroidManifest.xml 中声明此 Activity ?

标签 android xml

我想在我的项目中使用第三方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 步:摆脱您的 ComponentNamesetComponent() 调用

第 2 步:将您的 Intent 初始化替换为 Intent it = new Intent(this, ActivityImageDetail.class);,添加 import对于 ActivityImageDetail 如果需要的话

关于android - 您是否已在 AndroidManifest.xml 中声明此 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20869419/

相关文章:

java - 无法在 Android Studio 中添加操作栏项目

c# - 处理队列外的文件,归档并存储在数据库中

javascript - Javascript setTimeout() 和 WebConfig sessionState 超时之间的区别

xml - Google Directions API One Way 而不是起点和终点

android - Genymotion 2 - Google Play 商店无连接

android - 注销导航到上一个 Activity

android - 如何以编程方式关闭 Android 4.0 root 设备

java - smoothScrollTo(position) 滚动到底部而不是 RecyclerView 中的目标位置

android - 如何向这些现有编码添加滑动 View

xml - xsl :copy-of just the content without the node