Android的是的,我想关闭我打开的应用程序! [英] Android Yes I want to close the app I opened!

查看:122
本文介绍了Android的是的,我想关闭我打开的应用程序!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想开了,使用的应用程序,然后在一个按钮关闭的推动。我的问题是,我需要保持的应用现状单的数据,以便做到这一点?我的意思是,如果我对简历做完成的解决方案去()这意味着我需要保持每个活动着眼于收出一个全球性的数据?这是一个很好的,虽然笨拙的方式来关闭应用程序,但除非我听到不久另一种方式,我会去用它。

I have an app which I want to open, use, and then at the push of a button close. My question is do I need to keep singleton data of the application status in order to make this happen? I mean if I go with the solution of doing finish on resume() that means that I should need to keep a global data that each activity looks at to close out? This is a fine, albeit awkward way to close an app, but I'll go with it unless I hear another way soon.

感谢。

PS请不要与Android回应将决定何时以及如何处理您的应用程序做的。我很抱歉,但我知道我的用户不希望再次看到这个应用程序,他们单击完成后!而在最后,这是最重要的,他们是不是在所有感兴趣的是Android的需要与应用程序做的也不应该是。

PS please do not respond with android will decide when and what to do with your app. I'm sorry but I know my user does want to see this app again after they click Finish! And in the end that's what matters and they are not at all interested in what android needs to do with the app nor should they be.

推荐答案

好了,有也是为什么大家都说,并且是一样的:你不要关闭网页的理由。我不知道你的用户所期望的,但这是Android的方式/ iOS的工作。

Well, there is a reason why everyone says that, and is the same as "you don't close a web page". I don't know what your users might expect, but this is the way Android/iOS works.

我用,这样的事情你想做的事,标志ACTIVITY_CLEAR_TOP(您设置标志的意图打开包含关闭按钮活动),因此这样的活动栈被删除,只当前活动remaning:所以当你完成();应用关闭。

I've used, for something like what you want to do, the flag ACTIVITY_CLEAR_TOP (you set the flag on the intent to open the activity which contains the close button), so in this way the activity stack is deleted, only the current activity remaning: so when you do finish(); the app "closes".

Intent intent = new Intent(this, Some.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

这篇关于Android的是的,我想关闭我打开的应用程序!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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