onSaveInstanceState () and onRestoreInstanceState ()

前端 未结 13 2203
孤城傲影
孤城傲影 2020-11-22 04:48

I\'m trying to save and restore the state of an Activity using the methods onSaveInstanceState() and onRestoreInstanceState().

13条回答
  •  心在旅途
    2020-11-22 05:48

    I just ran into this and was noticing that the documentation had my answer:

    "This function will never be called with a null state."

    https://developer.android.com/reference/android/view/View.html#onRestoreInstanceState(android.os.Parcelable)

    In my case, I was wondering why the onRestoreInstanceState wasn't being called on initial instantiation. This also means that if you don't store anything, it'll not be called when you go to reconstruct your view.

提交回复
热议问题