-
-
Save KaustubhPatange/a3a0c5b40242483b9c189b231fa341ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity ... { | |
override fun onCreate(...) { | |
// This will work but has a catch. Do not implement this, | |
onBackPressedDispatcher.addCallback(object: OnBackPressedCallback(true) { | |
override fun handleOnBackPressed() { | |
if (shouldFinish()) { | |
this.remove() | |
onBackPressed() | |
onBackPressedDispatcher.addCallback(this) | |
} | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment