Kotlin.
Add the following to MainActivity.kt:
override fun onCreate(savedInstanceState: Bundle?) { ... ...
supportFragmentManager.addOnBackStackChangedListener {
supportFragmentManager.fragments.lastOrNull()?.onResume()
}
}
Then, add to AnyFragment.kt:
override fun onResume() {
super.onResume()
//txtEdit.requestFocusFromTouch()
}
Now, the onResume() will be called when the Fragment got the focus.