Android ViewModel recreated on screen rotation

前端 未结 4 1120
滥情空心
滥情空心 2021-02-14 11:01

I found a case when architecture components ViewModel isn\'t retained - in short it goes as follows:

  1. Activity is started and ViewModel in
4条回答
  •  清酒与你
    2021-02-14 11:26

    Change support library/compileSDK/targetSDK to 28.

    I had similar issue with multi-window. When switching to split screen, my viewModel is recreated. Support library 28 fixed my problem. (My lifecycle version is 1.1.1)

提交回复
热议问题