简体   繁体   English

使用 kotlin 的 Android studio 中的主页按钮

[英]Home button in Android studio with kotlin

I have created a splash screen for my app in Android studio using kotlin.我使用 kotlin 在 Android Studio 中为我的应用程序创建了启动画面。 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.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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