當Activty和Fragment被系統或者某些內存清理應用還有默認設置下的橫豎屏切換而被銷燬時,將會觸發onSaveInstanceState(Bundle savedInstanceState)(Fragment被detach時並不會觸發此方法),此時能夠將要保存的數據放入savedInstanceState中,以後在如下生命週期方法中取得保存的數據 spa
Activiyt.onCreate(Bundle savedInstanceState) 生命週期
Activiyt.onViewStateRestored(Bundle savedInstanceState) 內存
Fragment.onCreate(Bundle savedInstanceState) it
Fragment.onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 方法
Fragment.onActivityCreated(Bundle savedInstanceState) 數據
Fragment.onViewCreated(View view, Bundle savedInstanceState)
view
Fragment.onViewStateRestored(Bundle savedInstanceState)
vi