如何完成上登出的android多个活动多个、android

2023-09-12 05:34:45 作者:钻石般闪耀的男人i

在我的应用程序,我开始活动,一前一后另一个和调用另一个之前没有完成任何活动。但是,当用户presses注销按钮,然后我要完成从堆栈中的所有活动,并开始登录活动。

In my app i am starting activities one after the another and not finishing any activity before calling another. But when user presses logout button then i want to finish all the activities from the stack and start login activity.

活动登录(光洁度及放大器;调用) - > b活动 - >活动Ç - >   活动ð - >注销    - >活性的研究登录

Activity Login(finish & call) --> Activity B --> Activity C--> Activity D --> Logout -->Acitivity Login.

如果用户presses返回键上登录活动随后他返回到活动下在我的情况......但我想避免这种情况。

If user presses back key on login activity then he returns to Activity C in my case... but i want to avoid that.

推荐答案

你应该做的就是调用登录的活动,并清除栈之上的所有活动。

What you should do is call Login activity, and clear all activities above it in the stack.

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

这将标志它来创建一个新的登录活动,而不仅仅是恢复previous之一。并清除其上的所有活动。 (B,C,D)。

This will flag it to create a new login activity, not just resume the previous one. And clear all activities above it. (B, C, D).

 
精彩推荐
图片推荐