SyntaxFix
Write A Post
Hire A Developer
Questions
In Kotlin:
val callback = requireActivity().onBackPressedDispatcher.addCallback(this) { // Handle the back button event }
For more information you can check this.
There is also specific question about overriding back button in Kotlin.