Stack Overflow error android?
My code was running fine but suddenly when i ran the code again, it gave me stack overflow error. Following is my code:HelloDatePickerActivity has already been defined.
HelloDatePickerActivity daten=new HelloDatePickerActivity();
static final int DATE_DIALOG_ID = 0;
Button mPickDate;
TextView mDateDisplay;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.offline_screen);
mPickDate=(Button)findViewById(R.id.pickDate);
mPickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
daten.mDateSetListener,
daten.mYear, daten.mMonth, daten.mDay);
}
return null;
}
}
And the Logcat is:
08-26 15:38:50.039: ERROR/AndroidRuntime(585): FATAL EXCEPTION: main
08-26 15:38:50.039: ERROR/AndroidRuntime(585): java.lang.StackOverflowError
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at java.lang.Thread.currentThread(Thread.java:558)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at java.lang.ThreadLocal.get(ThreadLocal.java:53)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at android.os.Looper.myLooper(Looper.java:157)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at android.os.Handler.<init>(Handler.java:119)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at android.app.Activity.<init>(Activity.java:728)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:14)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePicke开发者_高级运维rActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerA
HelloDatePickerActivity daten=new HelloDatePickerActivity();
Here is your problem. Think about it.
Edit: Anyway, you must understand that calling new Activity()
is bad programming practice. Unfortunately I can't provide documentation reference saying that exact thing. Some relatively useful reference about creating new activities.
精彩评论