Skip to content

Instantly share code, notes, and snippets.

@KaustubhPatange
Created February 7, 2023 10:53
Show Gist options
  • Save KaustubhPatange/ad999d4213677915c90d9e7ae985ab43 to your computer and use it in GitHub Desktop.
Save KaustubhPatange/ad999d4213677915c90d9e7ae985ab43 to your computer and use it in GitHub Desktop.
// for fragment: requireActivity().onBackPressedDispatcher
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
// handle logic
if (shouldNotInvokeAgain) {
this.isEnabled = false
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment