Fragment A has got focus. When Fragment B is created, B gains the focus now. This causes A to lose focus, but it is still visible. Now if B is destroyed, A gains the focus again. As A regains focus, does its onResume()
method get called? If not, why?
(A and B are in the same activity.)
The onResume() method is not called in the case you describe. Check out the documentation on the android fragment lifecycle.
onResume() is called the first time the fragment is added to the UI, and then every time it comes back from being paused. A fragment would get paused if it is added to the back stack, the user hits the home button and hides the app, or if some other app takes over the phone (e.g. the user receives a phone call.) Generally speaking, if your fragment and app are fully visible, the fragment is not being paused.
UI focus should not be confused with the activity/fragment lifecycle. The situation that you are describing seems better suited for an OnFocusChangeListener.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With