Normally you would eventually keep the super method at the top(First Statement) so that its parent class is first called initialized.
以下代碼片段顯示了Activity#onSaveInstanceState(Bundle outState)
的外觀。您可以通過調用super.onSaveInstanceState(outState);
來看到它只保存了作爲參數傳入的Bundle。因此,在實際保存Bundle內部之前調用超級方法是沒有意義的。
protected void onSaveInstanceState(Bundle outState) {
outState.putBundle(WINDOW_HIERARCHY_TAG, mWindow.saveHierarchyState());
Parcelable p = mFragments.saveAllState();
if (p != null) {
outState.putParcelable(FRAGMENTS_TAG, p);
}
getApplication().dispatchActivitySaveInstanceState(this, outState);
}
因爲它調用保存實例,在主事件結束後如何保存您的個人設置? – deadfish
只對構造函數強制 – Blackbelt