I have a problem with saving the state of fragments which work with bottom navigation view. I am using the new android jetpack navigation library and it is really simple to code bottom navigation with fragments.
I have 3 fragments in the bottom navigation. When I switch, the fragments are recreated.
OnSaveInstanceState
is never called when I just switch between fragments, so it does not work.
I tried ViewModel
too, it works but I lose the recyclerview
position when I switch.
So I just want to simply save the state of fragments with recyclerviews
. I don't understand why this simple problem is so difficult to solve. Is there any proper way how to achieve this? I have done a lot of research but I have not found a solution. Thanks.