How To Confirm User Exit In Android App (Kotlin Code)

Image result for android kotlin
Image Source: Kotlin on Android. Now official (AndroidPub — jlelse)

App users often press the exit button unintentionally and the need to confirm a user’s exit is eminent. How about a toast that asks the user if the exit is intentional or not? We will be work through a sample code that does just that!

The aim of this article is to give you a heads up whenever you intend implementing an exit dialog in your android project.

Note: This article assumes that you are familiar with Android studio, Kotlin (Anko) and have an ongoing Android project. We will dive into the Kotlin code right away….

Show me the code

The Kotlin code is given below:

You can always copy and edit the code to fit your project need.

I am on a journey to explore the amazing world of Kotlin. You can catch me up on Twitter

--

--

Developer Relations: Working at the intersection of engineering, marketing and community management • @beacamphq @bunzzdev

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Trust Onyekwere

Trust Onyekwere

Developer Relations: Working at the intersection of engineering, marketing and community management • @beacamphq @bunzzdev