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

Trust Onyekwere
1 min readJun 25, 2019
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

--

--

Trust Onyekwere
Trust Onyekwere

Written by Trust Onyekwere

A human mingling around Blockchain 🔑 & Developer Relations 🎙️

No responses yet