完成所有的previous活动 [英] Finish all previous activities

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

问题描述

我的应用程序有以下流程

My application has the following flow

首页>屏幕1→屏幕2→屏幕3→屏幕4- GT;屏幕5

现在我在每个屏幕的共同注销按钮(

Now I have a common log out button in each screen (Home/ screen 1 / screen 2 /screen 3/ screen 4 / screen 5)

我想,当用户点击注销按钮(在任何屏幕),所有的屏幕都将被完成,一个新的屏幕登录将打开。

I want that when user clicks on the log out button(from any screen), all the screens will be finished and a new screen Log in will open .

我已经尝试了几乎所有的 FLAG_ACTIVITY 来实现这一目标。 我也去通过计算器一些答案,但不能够解决这个问题。 我的应用程序是在Android 1.6所以不能够使用 FLAG_ACTIVITY_CLEAR_TASK

I have tried nearly all FLAG_ACTIVITY to achieve this. I also go through some answers in stackoverflow, but not being able to solve the problem. My application is on Android 1.6 so not being able to use FLAG_ACTIVITY_CLEAR_TASK

有没有什么办法可以解决这个问题呢?

Is there any way to solve the problem ?

推荐答案

使用:

Intent intent = new Intent(getApplicationContext(), Home.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

这将清除家顶级所有活动。

This will clear all the activities on top of home.

假设你从1完成登录屏幕创建在用户登录和家的时候,之后所有的屏幕以5在那一个顶部。在codeI发布将返回到主屏幕完成所有其他activites。您可以添加一个额外的意图和读取,在主屏幕上的活动,并完成它也(可能再次启动登录屏幕从那里或什么的)。

Assuming you are finishing the login screen when the user logs in and home is created and afterwards all the screens from 1 to 5 on top of that one. The code i posted will return you to home screen finishing all the other activites. You can add an extra in the intent and read that in the home screen activity and finish it also (maybe launch login screen again from there or something).

我不知道,但你也可以尝试去登录使用该标志。我不知道怎么的活动将在这种情况下,订购。所以,不知道这是否会清除你在其中一个屏幕下方的是当前的那些,但它肯定是要走的路。

I am not sure but you can also try going to login with this flag. I don't know how the activities will be ordered in that case. So don't know if it will clear the ones below the screen you are on including the one you are currently on but its definitely the way to go.

希望这有助于。

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

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