我刚刚完成登录,但是当用户第一次登录并返回到登录屏幕时。我不知道为什么,但当你现在第二次打开应用程序时,如果一切正常(你返回并关闭应用程序),我想知道为什么第一次它会回到登录屏幕。这是我的代码:
val user = FirebaseAuth.getInstance().currentUser
if (user != null) {
val intent = Intent(this, home::class.java)
startActivity(intent)
finish()
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}发布于 2020-12-10 05:23:38
您应该在使用intent之前添加.setflag。我也会使用Intent.FLAG_ACTIVITY_CLEAR_TASK-flag -试试这个:
val user = FirebaseAuth.getInstance().currentUser
if (user != null) {
val intent = Intent(this, home::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
finish()
}https://stackoverflow.com/questions/65221363
复制相似问题