Skip to content

Instantly share code, notes, and snippets.

@KaustubhPatange
Created February 8, 2023 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaustubhPatange/0f44e4005a642a83d923aa8003447e69 to your computer and use it in GitHub Desktop.
Save KaustubhPatange/0f44e4005a642a83d923aa8003447e69 to your computer and use it in GitHub Desktop.
class MainActivity : BackPressCompatActivity() {
override fun onCreate(...) {
setOnBackPressListener { handleBackPress() }
...
}
private fun handleBackPress(): Boolean {
// perform action
...
if (shouldClose()) {
return true
}
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment