错误“无法找到显式活动类”

时间:2014-08-28 09:43:38

标签: java android android-intent

我知道以前问过上面的问题,但是当我在互联网上寻找解决方案时......我找不到解决问题的方法。

SingleMenuItemActivity的导航工作正常,所以我不知道为什么复制这个woulr不起作用。

更新:

问题是(因为它一直是这样的事情),是我导航到一个甚至不存在的页面...检查你确定你正在naivgating的页面拼写正确。

这是意图代码:

Intent i = new Intent(getApplicationContext(), AndroidXMLParsingChamp.class);
startActivity(i); 

这是清单 (我引用的代码标有'<!-- The class I am navigating to -->':

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidhive.xmlparsing"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".AndroidXMLParsingActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Single List Item View -->
        <activity
            android:label="Single Menu Item"
            android:name=".SingleMenuItemActivity" >
        </activity>

         <!-- The class I am navigating to -->
        <activity
            android:label="Single Menu Item"
            android:name=".AndroidXMLParsingActivityChamp" >
        </activity>

         <!--  <activity android:name="com.example.rssapplication.AndroidXMLParsingActivity" android:label="@string/app_name">  
         <intent-filter> 
           <action android:name="android.intent.action.AndroidXMLParsingActivityChamp" />  
             <category android:name="android.intent.category.DEFAULT" />  
         </intent-filter>   
      </activity>

         <activity android:name="com.example.rssapplication.AndroidXMLParsingActivityChamp" android:label="@string/app_name">  
         <intent-filter> 
           <action android:name="android.intent.action.AndroidXMLParsingActivity" />  
             <category android:name="android.intent.category.DEFAULT" />  
         </intent-filter>   
      </activity>-->
    </application>

    <uses-permission android:name="android.permission.INTERNET" />

</manifest>

logcat的:

08-28 10:19:05.486: E/AndroidRuntime(3041): FATAL EXCEPTION: main
08-28 10:19:05.486: E/AndroidRuntime(3041): Process: com.androidhive.xmlparsing, PID: 3041
08-28 10:19:05.486: E/AndroidRuntime(3041): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidhive.xmlparsing/com.androidhive.xmlparsing.AndroidXMLParsingChamp}; have you declared this activity in your AndroidManifest.xml?
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1648)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1442)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.Activity.startActivityForResult(Activity.java:3511)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.Activity.startActivityForResult(Activity.java:3472)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.Activity.startActivity(Activity.java:3714)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.Activity.startActivity(Activity.java:3682)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at com.androidhive.xmlparsing.AndroidXMLParsingActivity.onTouchEvent(AndroidXMLParsingActivity.java:94)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.Activity.dispatchTouchEvent(Activity.java:2548)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2228)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.View.dispatchPointerEvent(View.java:8315)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4590)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4458)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4020)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4074)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4043)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4150)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4051)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4207)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4020)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4074)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4043)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4051)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4020)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6397)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6301)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6272)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6237)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6477)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.os.MessageQueue.nativePollOnce(Native Method)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.os.MessageQueue.next(MessageQueue.java:138)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.os.Looper.loop(Looper.java:123)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at android.app.ActivityThread.main(ActivityThread.java:5356)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at java.lang.reflect.Method.invokeNative(Native Method)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at java.lang.reflect.Method.invoke(Method.java:515)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
08-28 10:19:05.486: E/AndroidRuntime(3041):     at dalvik.system.NativeStart.main(Native Method)

2 个答案:

答案 0 :(得分:2)

您尝试启动AndroidXMLParsingChamp,但在Manifest AndroidXMLParsingActivityChamp中声明了其他名称。此外,你在那里有重复的声明。

答案 1 :(得分:0)

您需要声明Activity HomePage是AndroidManifest.xml

 <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:theme="@style/AppTheme" >

        . . .
        <activity android:name="com.androidhive.xmlparsing.AndroidXMLParsingChamp" /> 
        . . .
</application>

有关详细信息,请参阅documentation