Clear activity stack in android

不问归期 提交于 2019-12-03 21:54:04

Simple, set an onclick on your logout button and then add this to your intent:

Intent newIntent = new Intent(this, login.class);

    newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    startActivity(newIntent);
    finish();

This should clear your entire stack above login.class

And if you're feeling real fun today, add

    newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

Which will get rid of that annoying "show the android homescreen" issue on the S3

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