从fragment启动时无法找到显式活动类

时间:2013-08-25 05:43:24

标签: android android-fragments android-activity

我有一个片段,我正试图通过按钮点击这样开始另一个活动:

Intent i = new Intent(getActivity(), RoundPagerActivity.class);
// put extras
startActivity(i);

应用程序在startActivity(i)的{​​{1}}来电时崩溃。这是logcat:

Fatal Exception

这是我的清单文件:

08-24 22:08:12.625: D/AndroidRuntime(9865): Shutting down VM 
08-24 22:08:12.625: W/dalvikvm(9865): threadid=1: thread exiting with uncaught exception(group=0x40c231f8) 
08-24 22:08:12.720: E/AndroidRuntime(9865): FATAL EXCEPTION: main 
08-24 22:08:12.720: E/AndroidRuntime(9865): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.wilk.android.tablink/com.wilk.android.tablink.RoundPagerActivity}; have you declared this activity in your AndroidManifest.xml? 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1511) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1387) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.app.Activity.startActivityForResult(Activity.java:3190) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:826) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.support.v4.app.Fragment.startActivity(Fragment.java:838) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at com.wilk.android.tablink.RoundListFragment.onListItemClick(RoundListFragment.java:94) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.widget.AdapterView.performItemClick(AdapterView.java:292) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.widget.AbsListView.performItemClick(AbsListView.java:1175) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2703) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.widget.AbsListView$1.run(AbsListView.java:3456) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.os.Handler.handleCallback(Handler.java:605) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.os.Handler.dispatchMessage(Handler.java:92) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.os.Looper.loop(Looper.java:137) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at android.app.ActivityThread.main(ActivityThread.java:4507) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at java.lang.reflect.Method.invokeNative(Native Method) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at java.lang.reflect.Method.invoke(Method.java:511) 
08-24 22:08:12.720: E/AndroidRuntime(9865):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 
    08-24 22:08:12.720: E/AndroidRuntime(9865):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 
    08-24 22:08:12.720: E/AndroidRuntime(9865):     at dalvik.system.NativeStart.main(Native Method)

奇怪的是我有另一个应用程序,它以同样的方式执行此操作。 我在这里看了其他问题,我很确定我已经用尽了那些选择,至少那些似乎适用的选择。我试图在新活动中设置断点但没有被击中。任何人都可以看到我新近被忽视的东西吗?

1 个答案:

答案 0 :(得分:8)

你的清单中拼错了。您有:android:name="com.wilk.android.tablink.RoundPagerAcivity"它应该是android:name="com.wilk.android.tablink.RoundPagerActivity"

另外,我不知道这是否重要,但在我的应用程序中,我也有“详细”活动的属性,如下所示:

    <activity
        android:name="com.wilk.android.tablink.RoundPagerActivity"
        android:label="@string/app_name"
        android:parentActivityName="com.wilk.android.tablink.RoundListActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.wilk.android.tablink.RoundListActivity" />
    </activity>