I am using android navigation components library. I have two fragments set up with navigation graph. I want to do some additional actions on back button press inside of my fragment.
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return NavigationUI.onNavDestinationSelected(item, view!!.findNavController())
|| super.onOptionsItemSelected(item)
}
I use this code to handle toolbar up button click, but I also want to handle back button press. How can I do this?