Intent.FLAG_ACTIVITY_CLEAR_TOP不工作 [英] Intent.FLAG_ACTIVITY_CLEAR_TOP not working

查看:280
本文介绍了Intent.FLAG_ACTIVITY_CLEAR_TOP不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的申请流程:

登录 - >简介 - > UpdateProfile-> ChangePass

Login->Profile->UpdateProfile->ChangePass

所有我activitys延伸FragmentActivity

当我在ChangePass活动preSS按钮,我称之为code:

When I press button in ChangePass Activity I call this code:

Intent intent=new Intent(getApplicationContext(),LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

所以它应该开始LoginActivity当我preSS回从LoginActivity那么应用程序应该关闭......但是当我preSS从登录活动后退按钮的流程是:

So It should start LoginActivity and when I press back from LoginActivity then Application should close...But When I press back button from Login Activity the flow is:

ChangePass-> UpdateProfile->简介 - >登录

ChangePass->UpdateProfile->Profile->Login

为什么我的背堆栈不被清除?

请注意:

我已经申请所有这些解决方案,但不工作:
1.link
2.link

I have applied all these solutions but not working: 1.link 2.link

推荐答案

请尝试以下方法 -

Try the following way -

 Intent intent = new Intent(getActivity(), LoginActivity.class);
 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
 startActivity(intent);
 finish();

有关更多的选择和细节检查<一href=\"http://stackoverflow.com/questions/14209124/intent-flag-activity-clear-top-doesnt-deletes-the-activity-stack\">intent-flag-activity-clear-top-doesn't-deletes-the-activity-stack.后解释,结果code完美,与上述解决方案。

For more alternatives and details check intent-flag-activity-clear-top-doesn't-deletes-the-activity-stack. The post explains with the result code perfectly and with the above solution.

这篇关于Intent.FLAG_ACTIVITY_CLEAR_TOP不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆