在Android应用程序中清除backstack按钮点击 [英] Clear backstack of application in android on button click

查看:122
本文介绍了在Android应用程序中清除backstack按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的应用程序中,我想明确的退出按钮的点击都是我背栈。
我已经搜索并尝试了多种解决方案,给出,但它不是为我工作。
请如果有人可以帮助我,这将是AP preciated。

我曾尝试下面的注销按钮,点击code

  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

和也试过以下清单文件code

 的android:launchMode =singleTop

感谢您在高级

感谢名单给大家的宝贵回复

我已经找到一个解决方案,并试图这又是为我工作得很好。

 意向意图=新意图(Settings.this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
                Intent.FLAG_ACTIVITY_CLEAR_TASK |
                Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(意向);
完();


解决方案

  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TASK);

以上为我工作,但 Intent.FLAG_ACTIVITY_CLEAR_TASK 可从API 11

I am developing app in which i want clear all my back-stack on click of log out button. i have searched and tried many solutions given but its not working for me. please if anyone can help me that would be appreciated.

i have tried following code on click of log out button

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

and also tried following code in manifest file

android:launchMode="singleTop"

Thank you in advanced

Thanx to all of you for your valuable reply

i have found one solution and tried this again was worked for me fine

Intent intent = new Intent(Settings.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | 
                Intent.FLAG_ACTIVITY_CLEAR_TASK |
                Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();

解决方案

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TASK);

above is working for me but Intent.FLAG_ACTIVITY_CLEAR_TASK is available from API 11

这篇关于在Android应用程序中清除backstack按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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