我得到了一些奇怪的日志,这显然只发生在版本低于 3 的 Android 设备上(用模拟器检查)。当您更改方向并使用不为空的 Bundle 调用 onCreate() 或 onRestoreInstanceState() 时,它会崩溃
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_menu);}
if (savedInstanceState != null) {
mSlug = savedInstanceState.getString(KEY_SLUG, null);
}
}@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_SLUG, mSlug);
}@Override
protected void onRestoreInstanceState(Bundle outState) {
super.onRestoreInstanceState(outState);
if (outState != null) {
mSlug = outState.getString(KEY_SLUG, mSlug);
}
}
LogCat-Log 看起来像:http: //i.stack.imgur.com/WbivQ.png 有人知道这里发生了什么吗?