user5246143
user5246143

Reputation: 31

Jetpack Navigation fragment lifecycle not right

I tried to change my old project to Androidx and Navigation. I used navigate to second Fragment, but if I close second Fragment too fast, it will not run onDestroyView and onDestroy, my screen gets blocked by white.

Normal lifecycle is :

E: Match   onAttach
E: Match   onCreate
E: Match   onViewCreated
E: Match   onStart
E: Match   onResume
E: Register   onPause
E: Register   onStop
E: Register   onDestroyView

My project's lifecycle is :

E: MineFragmentNew   onPause
E: MineFragmentNew   onStop
E: SettingFragment   onAttach
E: SettingFragment   onCreate
E: SettingFragment   onViewCreated
E: SettingFragment   onStart
E: MineFragmentNew   onDestroyView
E: SettingFragment   onResume

If I close too fast :

E: MineFragmentNew   onPause
E: MineFragmentNew   onStop
E: SettingFragment   onAttach
E: SettingFragment   onCreate
E: SettingFragment   onViewCreated
E: SettingFragment   onStart
E: SettingFragment   onStop
E: MineFragmentNew   onStart
E: MineFragmentNew   onResume

It's an old project done by others. I tried to change a lot of settings.

Upvotes: 2

Views: 507

Answers (1)

user5246143
user5246143

Reputation: 31

I found the problem ,it's Androidx,Fragment:1.3.0-beta01 https://developer.android.com/jetpack/androidx/releases/fragment#1.3.0-beta01

https://issuetracker.google.com/issues/167092035

It seems Fragment:1.3.0-beta02 will fixed ,but not now. Now use FragmentManager.enableNewStateManager(false) can fix it.

Upvotes: 1

Related Questions