Android学习之路之activity声明
今天学习新建多个activity,可是自己做的时候怎么运行都不行,后来看logcat,发现问题所在
现在logcat如下:
08-04 21:06:25.928 5551-5572/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.Restarter.getActivities
08-04 21:06:39.244 5551-5551/com.dereon.day0804intent E/AndroidRuntime: FATAL EXCEPTION: main
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.dereon.day0804intent/com.dereon.day0804intent.SecondActivity}; ***have you declared this activity in your AndroidManifest.xml?***
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
at android.app.Activity.startActivityForResult(Activity.java:3370)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:3331)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:871)
at android.app.Activity.startActivity(Activity.java:3566)
at android.app.Activity.startActivity(Activity.java:3534)
at com.dereon.day0804intent.MainActivity$1$override.onClick(MainActivity.java:22)
at com.dereon.day0804intent.MainActivity$1$override.access$dispatch(MainActivity.java)
at com.dereon.day0804intent.MainActivity$1.onClick(MainActivity.java:0)
at android.view.View.performClick(View.java:4204)
at android.view.View$PerformClick.run(View.java:17355)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
08-04 21:07:16.960 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources
08-04 21:07:16.964 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.pruneResourceCache
08-04 21:07:17.064 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.068 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.068 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.068 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.076 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.080 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.080 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.080 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.transition.TransitionManager', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.080 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.084 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.084 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.088 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.dereon.day0804intent.MainActivity.access$super
08-04 21:07:17.968 9116-9116/com.dereon.day0804intent E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
如上红色字体,我们在新建多个activity的时候要在AndroidManifest.xml中把每一个activity都要声明出来,这样才能在父级activity中对其进行调用