且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android的清除活性栈

更新时间:2023-11-19 11:25:34

很简单,在你的注销按钮设置一个onclick,然后添加到您的意图:

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

这应该清除上面的login.class整个堆栈

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

这将摆脱恼人的展示了Android主屏幕上的S3问题

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