Skip to content

Instantly share code, notes, and snippets.

@ibrahim-mrq
Created November 24, 2022 08:42
Show Gist options
  • Select an option

  • Save ibrahim-mrq/1ca81b173f1e7834de619d414514256e to your computer and use it in GitHub Desktop.

Select an option

Save ibrahim-mrq/1ca81b173f1e7834de619d414514256e to your computer and use it in GitHub Desktop.
override fun onBackPressed() {
if (backPressedTime + 2000 > System.currentTimeMillis()) {
backToasty!!.cancel()
super.onBackPressed()
return
} else {
backToasty = Toast.makeText(this, getString(R.string.back_exit), Toast.LENGTH_SHORT)
backToasty!!.show()
}
backPressedTime = System.currentTimeMillis()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment