Intent.FLAG_ACTIVITY_CLEAR_TOP not working

自闭症网瘾萝莉.ら 提交于 2019-12-04 08:23:17

Very late reply though.
But might help others as it worked for me.

Developers sometimes confuse FLAG_ACTIVITY_CLEAR_TASK with FLAG_ACTIVITY_CLEAR_TOP

Use this instead
intentRestart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

My God

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();

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.

Instead of replacing the old flags try appending one. Setflag replace theold flags.

Try using addFlags.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!