I am listening to the back button pressed on my fragment as follows:
requireActivity().onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
Log.d("backbuttonpressed", "backbuttonpressed ...")
isEnabled = false
requireActivity().onBackPressedDispatcher.onBackPressed()
}
})
When I pressed the back button at the bottom (screenshot), the hardware back button, the callback gets called but when I press the back button at the top bar it does not get called.
Is there any way to way to know if the top back button has been pressed in Android?
Here is the screenshot of back buttons.