android.content.ActivityNotFoundException:UnabletofindexplicitactivityclasshaveyoudeclaredthisactivityinyourAndroidManifest.xml?

無聲勝有聲發表於2015-10-23

  在整合PullToRefresh的時候出現如下異常

10-22 23:20:01.826  32331-32331/com.example.news.andoridnewsapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.news.andoridnewsapp, PID: 32331
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.news.andoridnewsapp/com.example.news.andoridnewsapp.PullToRefreshListFragmentActivity}; have you declared this activity in your AndroidManifest.xml?
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
            at android.app.Activity.startActivityForResult(Activity.java:3442)
            at android.app.Activity.startActivityForResult(Activity.java:3403)
            at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:813)
            at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:871)
            at android.support.v4.app.Fragment.startActivity(Fragment.java:916)
            at com.example.news.andoridnewsapp.NavigationDrawerFragment$1.onItemClick(NavigationDrawerFragment.java:137)
            at android.widget.AdapterView.performItemClick(AdapterView.java:299)
            at android.widget.AbsListView.performItemClick(AbsListView.java:1115)
            at android.widget.AbsListView$PerformClick.run(AbsListView.java:2913)
            at android.widget.AbsListView$3.run(AbsListView.java:3680)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5047)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
            at dalvik.system.NativeStart.main(Native Method)

  解決辦法:

  在主工程的AndroidManifest.xml中新增宣告

<activity android:name=".PullToRefreshListFragmentActivity"></activity>