Android应用程序退出按钮

Android应用程序退出按钮

本文介绍了Android应用程序退出按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我是否需要添加一个退出按钮,我的应用程序。有没有点这样做呢?如果在离开一个活动或服务不.finish()或正常关闭可能这会造成很大的伤害?

解决方案

您并不需要添加连接退出按钮。如果不这样做,你的活动将只是保存在内存中,直到系统回收它。它不会消耗任何CPU。

当然,如果您有任何工作线程运行,你应该停止他们的onStop(),或在onPause(),这取决于你的线程在做什么。

许多应用程序添加一个退出按钮,出于某种原因。我想原因是,他们不相信自己写正确的code或不信任的Andr​​oid操作系统来收拾妥当。

不打算通过正确的完成过程不会造成对他人的损害比你。

I'm not sure whether I need to add an exit button to my app. Is there any point to doing this? And if on exiting one activity or service is not .finish() or closed properly could this cause a lot of damage?

解决方案

You don't need to add en exit button. If you don't, your activity will just be kept in memory until the system reclaims it. It will not consume any cpu.

Of course, if you have any worker threads running you should stop them in onStop() or onPause(), depending on what your threads are doing.

Many applications add an exit button, for some reason. I guess the reason is that they don't trust themselves to write proper code or they don't trust the Android OS to clean up properly.

Not going through the correct finish procedures will not cause any damage to others than yourself.

这篇关于Android应用程序退出按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 08:19