如何完成上登出的android多个活动 [英] How to finish multiple activities on logout android

查看:87
本文介绍了如何完成上登出的android多个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我开始活动,一前一后另一个和调用另一个之前没有完成任何活动。但是,当用户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).

这篇关于如何完成上登出的android多个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆