我知道这种类型的错误存在一些问题,但我的只是随机发生,我还没有找到导致它的原因。这是错误日志:
11-02 16:41:58.448: E/AndroidRuntime(13702): FATAL EXCEPTION: main
11-02 16:41:58.448: E/AndroidRuntime(13702): java.lang.StackOverflowError
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.text.SpannableString.getSpans(SpannableString.java:25)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.text.TextUtils.writeToParcel(TextUtils.java:615)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.widget.TextView$SavedState.writeToParcel(TextView.java:8781)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeParcelable(Parcel.java:1254)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1173)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeSparseArray(Parcel.java:662)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1198)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.java:1170)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeMapInternal(Parcel.java:591)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Bundle.writeToParcel(Bundle.java:1646)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeBundle(Parcel.java:605)
11-02 16:41:58.448: E/AndroidRuntime(13702): at android.os.Parcel.writeValue(Parcel.
我的应用只有 1Activity
和 2 TextView
、 2Button
和 1EditText
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
onSaveInstanceState(newBundy);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
onSaveInstanceState(newBundy);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBundle("newBundy", newBundy);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
savedInstanceState.getBundle("newBundy");
}
我评论了上面的行,现在没有崩溃,为什么这段代码会导致它崩溃?