我正在尝试从对话框开始另一个活动,但是如果我在模拟器中运行,我会关闭这个力。如何解决这个问题?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
boolean firstrun= true;
if (firstrun) {
AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("This is First Run !").setMessage("Welcome! Please enter the emergency numbers!");
builder.setPositiveButton("OK!", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent sv = new Intent(getApplicationContext(),com.sach.droidclinic.Save.class);
startActivity(sv);
}
});
AlertDialog dialogue = builder.create();
dialogue.show();
}
这是我随问题附上的原木猫,
11-10 21:48:58.250: D/dalvikvm(410): GC_EXTERNAL_ALLOC freed 50K, 53% free 2543K/5379K, external 716K/1038K, paused 107ms
11-10 21:49:24.450: D/AndroidRuntime(410): Shutting down VM
11-10 21:49:24.450: W/dalvikvm(410): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-10 21:49:24.469: E/AndroidRuntime(410): FATAL EXCEPTION: main
11-10 21:49:24.469: E/AndroidRuntime(410): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.sach.droidclinic/com.sach.droidclinic.Save}; have you declared this activity in your AndroidManifest.xml?
11-10 21:49:24.469: E/AndroidRuntime(410): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
11-10 21:49:24.469: E/AndroidRuntime(410): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
11-10 21:49:24.469: E/AndroidRuntime(410): at android.app.Activity.startActivityForResult(Activity.java:2827)
11-10 21:49:24.469: E/AndroidRuntime(410): at android.app.Activity.startActivity(Activity.java:2933)
11-10 21:49:24.469: E/AndroidRuntime(410): at com.sach.droidclinic.MainActivity$1.onClick(MainActivity.java:32)
11-10 21:49:24.469: E/AndroidRuntime(410): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
11-10 21:49:24.469: E/AndroidRuntime(410): at android.os.Handler.dispatchMessage(Handler.java:99)
11-10 21:49:24.469: E/AndroidRuntime(410): at android.os.Looper.loop(Looper.java:123)
11-10 21:49:24.469: E/AndroidRuntime(410): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-10 21:49:24.469: E/AndroidRuntime(410): at java.lang.reflect.Method.invokeNative(Native Method)
11-10 21:49:24.469: E/AndroidRuntime(410): at java.lang.reflect.Method.invoke(Method.java:507)
11-10 21:49:24.469: E/AndroidRuntime(410): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-10 21:49:24.469: E/AndroidRuntime(410): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-10 21:49:24.469: E/AndroidRuntime(410): at dalvik.system.NativeStart.main(Native Method)
11-10 21:50:01.749: D/dalvikvm(440): GC_EXTERNAL_ALLOC freed 51K, 53% free 2543K/5379K, external 716K/1038K, paused 216ms
11-10 21:50:08.658: D/AndroidRuntime(440): Shutting down VM
11-10 21:50:08.658: W/dalvikvm(440): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-10 21:50:08.689: E/AndroidRuntime(440): FATAL EXCEPTION: main
11-10 21:50:08.689: E/AndroidRuntime(440): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.sach.droidclinic/com.sach.droidclinic.Save}; have you declared this activity in your AndroidManifest.xml?
11-10 21:50:08.689: E/AndroidRuntime(440): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
11-10 21:50:08.689: E/AndroidRuntime(440): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
11-10 21:50:08.689: E/AndroidRuntime(440): at android.app.Activity.startActivityForResult(Activity.java:2827)
11-10 21:50:08.689: E/AndroidRuntime(440): at android.app.Activity.startActivity(Activity.java:2933)
11-10 21:50:08.689: E/AndroidRuntime(440): at com.sach.droidclinic.MainActivity$1.onClick(MainActivity.java:32)
11-10 21:50:08.689: E/AndroidRuntime(440): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
11-10 21:50:08.689: E/AndroidRuntime(440): at android.os.Handler.dispatchMessage(Handler.java:99)
11-10 21:50:08.689: E/AndroidRuntime(440): at android.os.Looper.loop(Looper.java:123)
11-10 21:50:08.689: E/AndroidRuntime(440): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-10 21:50:08.689: E/AndroidRuntime(440): at java.lang.reflect.Method.invokeNative(Native Method)
11-10 21:50:08.689: E/AndroidRuntime(440): at java.lang.reflect.Method.invoke(Method.java:507)
11-10 21:50:08.689: E/AndroidRuntime(440): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-10 21:50:08.689: E/AndroidRuntime(440): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-10 21:50:08.689: E/AndroidRuntime(440): at dalvik.system.NativeStart.main(Native Method)
11-10 21:51:12.799: D/dalvikvm(469): GC_EXTERNAL_ALLOC freed 41K, 53% free 2543K/5379K, external 716K/1038K, paused 108ms
11-10 21:51:18.382: D/AndroidRuntime(469): Shutting down VM
11-10 21:51:18.389: W/dalvikvm(469): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-10 21:51:18.415: E/AndroidRuntime(469): FATAL EXCEPTION: main
11-10 21:51:18.415: E/AndroidRuntime(469): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.sach.droidclinic/com.sach.droidclinic.Save}; have you declared this activity in your AndroidManifest.xml?
11-10 21:51:18.415: E/AndroidRuntime(469): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
11-10 21:51:18.415: E/AndroidRuntime(469): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
11-10 21:51:18.415: E/AndroidRuntime(469): at android.app.Activity.startActivityForResult(Activity.java:2827)
11-10 21:51:18.415: E/AndroidRuntime(469): at android.app.Activity.startActivity(Activity.java:2933)
11-10 21:51:18.415: E/AndroidRuntime(469): at com.sach.droidclinic.MainActivity$1.onClick(MainActivity.java:32)
11-10 21:51:18.415: E/AndroidRuntime(469): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
11-10 21:51:18.415: E/AndroidRuntime(469): at android.os.Handler.dispatchMessage(Handler.java:99)
11-10 21:51:18.415: E/AndroidRuntime(469): at android.os.Looper.loop(Looper.java:123)
11-10 21:51:18.415: E/AndroidRuntime(469): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-10 21:51:18.415: E/AndroidRuntime(469): at java.lang.reflect.Method.invokeNative(Native Method)
11-10 21:51:18.415: E/AndroidRuntime(469): at java.lang.reflect.Method.invoke(Method.java:507)
11-10 21:51:18.415: E/AndroidRuntime(469): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-10 21:51:18.415: E/AndroidRuntime(469): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-10 21:51:18.415: E/AndroidRuntime(469): at dalvik.system.NativeStart.main(Native Method)