ActivityNotFoundException onBackPressed和onSaveInstanceState

时间:2016-04-27 08:47:31

标签: android

致命异常:android.content.ActivityNotFoundException:无法找到显式活动类{Myclass};你有没有在AndroidManifest.xml中声明这个活动?

在这两个被覆盖的方法中:

@Override
protected void onSaveInstanceState(Bundle outState) {
    if(result != null){
        outState = result.saveInstanceState(outState);
        super.onSaveInstanceState(outState);
    }
}

@Override
public void onBackPressed() {
    if (result != null && result.isDrawerOpen()) {
        result.closeDrawer();
    } else {
        super.onBackPressed();
    }
}

Logcat错误:

  

致命异常:android.content.ActivityNotFoundException:无法执行   找到显式活动类{Myclass};你宣布这个吗?   AndroidManifest.xml中的活动?在   android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1801)   在   android.app.Instrumentation.execStartActivity(Instrumentation.java:1514)   在android.app.Activity.startActivityForResult(Activity.java:3951)处   android.app.Activity.startActivityForResult(Activity.java:3912)at   android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)   在android.app.Activity.startActivity(Activity.java:4235)at   android.app.Activity.startActivity(Activity.java:4203)at   isd.com.al.posapp.DrawerActivity.restart(DrawerActivity.java:737)at at   isd.com.al.posapp.DrawerActivity $ 7.onClick(DrawerActivity.java:728)at at   com.android.internal.app.AlertController $ ButtonHandler.handleMessage(AlertController.java:163)   在android.os.Handler.dispatchMessage(Handler.java:102)at   android.os.Looper.loop(Looper.java:148)at   android.app.ActivityThread.main(ActivityThread.java:5527)at   java.lang.reflect.Method.invoke(Method.java)at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:730)   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

1 个答案:

答案 0 :(得分:2)

在项目的AndroidManifest.xml文件中声明您的活动,如下所示

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