简体   繁体   中英

Home button in Android studio with kotlin

I have created a splash screen for my app in Android studio using kotlin. When the home button is pressed in splash screen time, the app restarts and opens the next activity ie login activity instead of putting the app to background.

How can I put the app into background and avoid it to restart automatically when home button is pressed in splash screen time

Can you add this code to your splash screen activity?

override fun onPause() {
    super.onPause()
    finish()
}

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM