Android的 - 如何从应用程序退出 [英] android - How to Exit from the application
问题描述
我的申请有20项活动。在这里,我想实现的是如何从应用程序退出时,你点击按钮(如注销)。如果你的菜单按钮点击我们的应用程序的任何地方,然后它显示了一个按钮这个意思。如果上单击,然后直接从应用程序出来。如何实现它。
感谢
好纳雷什你可以做这样的事情
首先完成从中正在关闭应用程序this.finish活动();其次,最impotantly总是设置一个标志i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
当你从一个活动切换到另一个活动的这个明确的顶部和你知道每一项活动是保存在栈因此该标志由上删除旧的活动等等在你的整个应用程序只有一个活动被保存在栈<在顶推新活动/ p>
如果这不起作用把整个应用程序在后台由avtivityname.moveTaskToBack();这将移动您的整个应用程序在回地面,但只有一个,当你开始你的活动缺点,它会显示你从你已经搬回了活动
My Application have 20 activities. Here i want to implement the how to exit from the application when you click on the button(like Logout). it means if you click on the menu button any where of our application then it shows the one button. if click on that then directly comes out from the application. how to implement it.
thanks
Well naresh you can do something like that first finish the activity from which you are closing application this.finish(); secondly and most impotantly always set a flag i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); this clear top when you switch from one activity to another activity and as you know every activity is kept in stack to so this flag remove old activity from top and push new activity in top so around your whole application only one activity is kept in stack
and if this does not work put the whole application in background by avtivityname.moveTaskToBack(); this will move your whole app in back ground but only one drawback when you start your activity it will show your that activity from which you have moved back
这篇关于Android的 - 如何从应用程序退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!