have SavedStateHandle within ShareViewModel,
and in HomeFragment get the ShareViewModel from MainActivity,
also pass the ShareViewModel to HomeViewModel,
the problem is get null from SavedStateHandle after app relaunch from background
class ShareViewModel(
val stateHandle: SavedStateHandle
) : ViewModel(), KoinComponent {
val sharedResp: MutableLiveData<Resp?> = stateHandle.getLiveData(KEY_RESP, null)
fun getSharedResp(): Resp? {
return sharedResp.value
}
fun updateResp(resp: Resp) {
sharedResp.value = resp
}
}
class MainActivity : BaseActivity(R.layout.activity_main) {
private val shareViewModel: ShareViewModel by viewModel()
}
class HomeFragment : BaseFragment<FragmentHomeBinding>() {
private val shareViewModel: ShareViewModel by activityViewModel()
private val viewModel by viewModel<HomeViewModel> {
parametersOf(shareViewModel)
}
class HomeViewModel(
private val shareViewModel: ShareViewModel,
)
To Reproduce
Steps to reproduce the behavior:
Mobile open "Don't keep activities" toggle and run the app
put app into background
relaunch the app
the SavedStateHandle get null, but keep doing this circle about 3 times the SavedStateHandle get value back
Expected behavior
the SavedStateHandle shouldn't be null after relaunch app from background
Koin module and version:koin-core:3.4.3lifecycle-viewmodel-savedstate:2.5.1
Describe the bug
have SavedStateHandle within ShareViewModel, and in HomeFragment get the ShareViewModel from MainActivity, also pass the ShareViewModel to HomeViewModel, the problem is get null from SavedStateHandle after app relaunch from background
In the Modules:
To Reproduce Steps to reproduce the behavior:
Expected behavior the SavedStateHandle shouldn't be null after relaunch app from background
Koin module and version:
koin-core:3.4.3
lifecycle-viewmodel-savedstate:2.5.1