FLAG_ACTIVITY_CLEAR_TOP not working on 5.0+ devices

穿精又带淫゛_ 提交于 2020-01-17 04:14:05

问题


I use the FLAG_ACTIVITY_CLEAR_TOP intent flag to clear the stack when transitioning from a login activity to the main app - everything works perfectly in 4.x devices, but on lollipop it's not working. Just to add some code, here's what I'm calling:

Intent intent = new Intent(this, MyActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

I've tried using the FLAG_ACTIVITY_NEW_TASK flag in conjunction but that also hasn't helped.


回答1:


try these flags:

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);



回答2:


Use this

   intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);


来源:https://stackoverflow.com/questions/28944455/flag-activity-clear-top-not-working-on-5-0-devices

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