Search code examples
androidandroid-studiobuttonkotlinback

How to GoBack to the previous Activity ? Kotlin ( using a button outside the action bar)


Using a Kotlin code i want to know how to add a button outside the action bar which takes me to the previous Activity on click


Solution

  • You can call finish() when button is clicked

    button.setOnClickListener {
       finish()
    }