Status Update
Comments
il...@google.com <il...@google.com> #2
The behavior you're seeing is correct - onStop()
is called before the animation starts (and onStart()
is called even when you have called postponeEnterTransition()
and are awaiting your entering transition to start). We'll fix the documentation to make this more clear.
ma...@gmail.com <ma...@gmail.com> #3
Thanks for the answer. Is there a callback that I can use instead of onStop?
Our use case is the video player that we want to stop whenever uses puts the app into background, so we use onStop. But that also stops video awkwardly when user leaves the screen and sees frozen video while animating.
il...@google.com <il...@google.com> #4
onDestroyView()
is the signal that your View is being destroyed. When using AndroidX Transitions or the Animator API, onDestroyView()
is only called after those complete.
ma...@gmail.com <ma...@gmail.com> #5
Right, but onDestroyView is not called when app is going into the background. We need signal for both.
ma...@gmail.com <ma...@gmail.com> #6
To be more clear: We need to stop video when screen when either:
- application goes into the background
- screen is stopped (after animations)
If we listen to onStop, when we can detect the background (but not the exit since animation is still playing). If we listen to onDestroyView, we cannot detect when view goes into the background.
ma...@marcardar.com <ma...@marcardar.com> #7
I'm also experiencing that Fragment.onDestroyView() is NOT being called after the animation completes.
Description
According tohttps://developer.android.com/guide/fragments/lifecycle :
However, when fragment transitions are used (FragmentTransaction.setCustomAnimations or FragmentTransaction.setTransition), onStop will be called BEFORE fragment is no longer visible (onStop will be called when animation starts instead of when fragment disappears).
Component used: Fragment
Version used:
androidx.fragment:fragment:1.1.0
Devices/Android versions reproduced on: Android 10
To reproduce the bug:
Expected outcome:
Fragment should become green (onPause) while animating
Actual outcome:
Fragment becomes red (onStop).