onSaveInstanceState not working

前端 未结 3 1001
轮回少年
轮回少年 2021-01-07 09:16

I know this question has already been asked a lot, but I don\'t get why onSaveInstanceState isn\'t working for me. It\'s probably something stupid, but I hope some of you ca

3条回答
  •  [愿得一人]
    2021-01-07 09:27

    you are saving that in the local variable why ? may try this

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        this.ToDo = savedInstanceState.getStringArrayList("MyArrayList");
    }
    

    Usually you restore your state in onCreate. It is possible to restore it in onRestoreInstanceState as well, but not very common. (onRestoreInstanceState is called after onStart, whereas onCreate is called before onStart.

    from : onSaveInstanceState () and onRestoreInstanceState ()

提交回复
热议问题