我正在尝试开始一项新活动,但我的应用程序停止了。如果 if 条件为真,则执行注册活动并工作,但如果为假,则跟踪活动停止我的应用程序 这是代码:
if(condition)
{
Intent register = new Intent(HomeActivity.this, Register.class);
HomeActivity.this.startActivity(register);
}
else
{
Intent login = new Intent(HomeActivity.this, Track.class);
HomeActivity.this.startActivity(login);
}
也许这与我的 Track 课程有关?
日志猫:
12-21 15:46:16.265: D/AndroidRuntime(540): Shutting down VM
12-21 15:46:16.265: W/dalvikvm(540): threadid=1: thread exiting with uncaught exception (group=0x40c711f8)
12-21 15:46:16.265: E/AndroidRuntime(540): FATAL EXCEPTION: main
12-21 15:46:16.265: E/AndroidRuntime(540): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.location/com.example.android.location.HomeActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.android.location/com.example.android.location.Track}; have you declared this activity in your AndroidManifest.xml?
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.ActivityThread.access$600(ActivityThread.java:128)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.os.Handler.dispatchMessage(Handler.java:99)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.os.Looper.loop(Looper.java:137)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.ActivityThread.main(ActivityThread.java:4514)
12-21 15:46:16.265: E/AndroidRuntime(540): at java.lang.reflect.Method.invokeNative(Native Method)
12-21 15:46:16.265: E/AndroidRuntime(540): at java.lang.reflect.Method.invoke(Method.java:511)
12-21 15:46:16.265: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
12-21 15:46:16.265: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
12-21 15:46:16.265: E/AndroidRuntime(540): at dalvik.system.NativeStart.main(Native Method)
12-21 15:46:16.265: E/AndroidRuntime(540): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.android.location/com.example.android.location.Track}; have you declared this activity in your AndroidManifest.xml?
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1388)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.Activity.startActivityForResult(Activity.java:3281)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.Activity.startActivity(Activity.java:3388)
12-21 15:46:16.265: E/AndroidRuntime(540): at com.example.android.location.HomeActivity.onCreate(HomeActivity.java:44)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.Activity.performCreate(Activity.java:4562)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
12-21 15:46:16.265: E/AndroidRuntime(540): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
12-21 15:46:16.265: E/AndroidRuntime(540): ... 11 more