[英]Clear ALL activities in back stack
I have this stack:我有这个堆栈:
Login Activity -> Registration Activity登录活动 -> 注册活动
After a successful registration I call this:注册成功后,我称之为:
Intent i = new Intent(getApplicationContext(),Home.class);
i.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK );
startActivity(i);
finish();
And this finish my Registration activity BUT not my Login activity, so my stack stay like this:这完成了我的注册活动,但不是我的登录活动,所以我的堆栈保持这样:
Login Activity -> Home Activity登录活动 -> 主页活动
Any advice?有什么建议吗?
use this with intent in order to clear the backtrace activities有意使用它以清除回溯活动
Java爪哇
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Kotlin科特林
var intent = Intent(this, [Your_activity]:class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
To clear activities on the top of the stack ,要清除堆栈顶部的活动,
Intent i = new Intent(getApplicationContext(), Home.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra("EXIT", true);
startActivity(i);
finish();
Well, i ended up using this answer好吧,我最终使用了这个答案
Clear the entire history stack and start a new activity on Android 清除整个历史堆栈并在 Android 上启动一个新活动
And that do exactly what Im trying to do这正是我想要做的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.