如何清除活动堆栈上的按钮单击的Andr​​oid [英] How to clear Activity Stack on Button Click in Android

查看:242
本文介绍了如何清除活动堆栈上的按钮单击的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我有我的应用程序注销按钮,我们称之为一个应用程序的登录屏幕,但在这一点上,当用户preSS Android手机的返回按钮上,他在App无需再次认证进入了一个问题,这是不可取的。我想,当我们的退出按钮单击所有previous活动堆栈被清除,或者我们可以说,所有的previous的onPause活动已被清除。

I have a question that I have a logout button in my App on which we have called an App login Screen but at this point when user press the Back Button of Android Phone, he entered in the App again without Authentication, which is not desirable. I want when we click on Logout button All previous Activity Stack being cleared or we can say that All previous onPause Activities have to be cleared.

请我建议这个问题的解决方案。

Please Suggest me the right solution for this problem.

先谢谢了。

推荐答案

据我了解的登录屏幕将是第一个屏幕飞溅后的一个,所以如果登录界面是在栈可以再次调用登录界面就像下面为实现这一

As far as I understood the login screen would be the first screen after the splash one so if login screen is in stack you can call again login screen like the below to achieve this

Intent launch = new Intent(context, LoginActivity.class);
launch.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(launch);

这篇关于如何清除活动堆栈上的按钮单击的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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