android - 完成其他 Activity 之前的所有 Activity

标签 android android-intent android-activity

任何人都可以帮助我完成我的任务 我有一个 actvitiy,我在新的 Intent new activity 中打开,然后在这个新的 activiyt 中我再次打开新的 intent(previsios Activity 没有关闭,所以当我点击设备上的后退按钮时我可以返回到它们)。 我想写“退出按钮”并开始新 Activity ,我只能关闭一个 Previsios Activity ,但 pre-previsios 仍然打开。 理想情况下它是这样的 - MainActivity -> SettingsActivity -> LogoutActivity(这里我们必须回到 loginActivity) 我被试过了

 mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

但运气不好 :(

最佳答案

试试这个解决方案..

Intent i = new Intent(FirstActivity.this, SecondActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
           Intent.FLAG_ACTIVITY_CLEAR_TASK |
           Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

希望对您有所帮助。

关于android - 完成其他 Activity 之前的所有 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38268148/

相关文章:

android - 广播接收器未被调用

android - 单击通知未打开应用程序/Activity

android - 如何在 TableRow 中触发动态创建的按钮单击事件?

java - 使用改造向请求添加 header 时如何避免在主线程上等待?

android - 将 SQLite 中的记录显示到 ListView 中

android - Calendar.get(Calendar.HOUR)的问题

android - Eclipse/adb/DDMS : Samsung S2 4. 0.3 无法被 Eclipse 识别

android - 如何 "disable"外部应用程序的 Intent 过滤器?

java - android Activity 切换不起作用

android - 按下后退时不返回父 Activity