Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

android - 退出应用程序会感到皱眉吗?(Is quitting an application frowned upon?)

Moving on in my attempt to learn Android, I just read the following :

(继续尝试学习Android,我读了以下内容 :)

Question: Does the user have a choice to kill the application unless we put a menu option in to kill it? (问题: 除非我们放入菜单选项来杀死应用程序,否则用户是否可以选择杀死应用程序?)

If no such option exists, how does the user terminate the application? (如果不存在这样的选项,那么用户如何终止应用程序?) Answer: (Romain Guy): The user doesn't, the system handles this automatically. (答:(Roman Guy): 用户没有,系统会自动处理。)That's what the activity lifecycle (especially onPause/onStop/onDestroy) is for. (这就是活动生命周期(尤其是onPause / onStop / onDestroy)的用途。)No matter what you do, do not put a "quit" or "exit" application button. (无论您做什么,都不要放置“退出”或“退出”应用程序按钮。)It is useless with Android's application model. (它对Android的应用程序模型没有用。)This is also contrary to how core applications work. (这也与核心应用程序的工作方式相反。)

Hehe, for every step I take in the Android world I run into some sort of problem =(

(呵呵,我进入Android世界的每一步都会遇到某种问题=()

Apparently, you cannot quit an application in Android (but the Android system can very well totally destroy your app whenever it feels like it).

(显然,您无法在Android中退出应用程序(但是Android系统可以在需要时完全销毁您的应用程序)。)

What's up with that?

(那是怎么回事?)

I am starting to think that it's impossible to write an app that functions as a "normal app" - that the user can quit the app when he/she decides to do so.

(我开始认为编写一个充当“普通应用程序”的应用程序是不可能的-用户可以在决定退出应用程序时退出该应用程序。)

That is not something that should be relied upon the OS to do.

(那不是应该依靠操作系统来做的事情。)

The application I am trying to create is not an application for the Android Market.

(我尝试创建的应用程序不是适用于Android Market的应用程序。)

It is not an application for "wide use" by the general public, it is a business app that is going to be used in a very narrow business field.

(它不是公众“广泛使用”的应用程序,而是将在非常狭窄的业务领域中使用的商业应用程序。)

I was actually really looking forward to developing for the Android platform, since it addresses a lot of issues that exist in Windows Mobile and .NET.

(实际上,我真的很期待开发Android平台,因为它解决了Windows Mobile和.NET中存在的许多问题。)

However, the last week has been somewhat of a turnoff for me... I hope I don't have to abandon Android, but it doesn't look very good right now =(

(但是,上周对我来说是个休假……我希望我不必放弃Android,但现在看起来还不太好=()

Is there a way for me to really) quit the application?

(我有办法真正)退出该应用程序吗?)

  ask by community wiki translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This will eventually get to your question, but I first want to address a number of issues you raise in your various comments to the various answers already given at the time of this writing.

(这最终将解决您的问题,但是我首先想解决您在撰写本文时已经给出的各种答案的各种评论中提出的一些问题。)

I have no intention of changing your mind -- rather, these are here for others who come to read this post in the future.

(我无意改变您的想法-相反,这些是供将来阅读此帖子的其他人使用的。)

The point is that I cannot allow for Android to determine when my app is going to be terminated.

(关键是我不能允许Android确定何时终止我的应用。)

that must be the choice of the user.

(那必须是用户的选择。)

Millions of people are perfectly happy with the model where the environment closes up the application as needed.

(数以百万计的人对环境根据需要关闭应用程序的模型感到非常满意。)

Those users simply don't think about "terminating" the Android app, any more than they think about "terminating" a Web page or "terminating" a thermostat.

(这些用户根本不会考虑“终止” Android应用程序,而只是考虑“终止”网页或“终止”恒温器。)

iPhone users are much the same way, in that pressing the iPhone button does not necessarily "feel" like the app was terminated, since many iPhone apps pick up where the user left off, even if the app really was shut down (since iPhone only allows one third-party app at a time, at present).

(iPhone用户的使用方式大致相同,因为按下iPhone按钮并不一定像终止应用程序一样“感觉”,因为许多iPhone应用程序从用户离开的地方接起,即使该应用程序确实关闭了(因为仅iPhone)目前一次允许一个第三方应用)。)

As I said above, there is a lot of things going on in my app (data being PUSHed to the device, lists with tasks that always should be there, etc.).

(正如我上面所说的,我的应用程序中发生了很多事情(将数据推送到设备上,列出了总是应该存在的任务等)。)

I don't know what "lists with tasks that always should be there" means, but the "data being PUSHed to the device" is a pleasant fiction and should not be done by an activity in any case.

(我不知道“列出应该始终存在的任务”是什么意思,但是“将数据推送到设备上”是一种令人愉快的小说,无论如何都不应该由活动来完成。)

Use a scheduled task (via AlarmManager ) to update your data for maximum reliability.

(使用计划的任务(通过AlarmManager )来更新您的数据以获得最大的可靠性。)

Our users log in and can't be doing that every time they get a phone call and Android decides to kill the app.

(我们的用户每次登录都会登录,并且不能这样做,而Android决定终止该应用程序。)

There are many iPhone and Android applications that deal with this.

(有很多iPhone和Android应用程序都可以解决这个问题。)

Usually, it is because they hold onto logon credentials, rather than forcing users to log in every time manually.

(通常是因为它们保留登录凭据,而不是强迫用户每次手动登录。)

For example, we want to check updates when exiting the application

(例如,我们要在退出应用程序时检查更新)

That is a mistake on any operating system.

(在任何操作系统上,这都是一个错误。)

For all you know, the reason your application is being "exited" is because the OS is shutting down, and then your update process will fail mid-stream.

(就您所知,您的应用程序“退出”的原因是因为操作系统正在关闭,然后您的更新过程中途会失败。)

Generally, that's not a good thing.

(通常,这不是一件好事。)

Either check updates on start or check updates totally asynchronously (eg, via a scheduled task), never on exit.

(要么在启动时检查更新,要么完全异步地检查更新(例如,通过计划的任务),而从不退出。)

Some comments suggest that hitting the back button does not kill the app at all (see link in my question above).

(一些评论表明,单击“后退”按钮根本不会杀死该应用程序(请参阅上面我的问题的链接)。)

Pressing the BACK button does not "kill the app".

(按下“返回”按钮不会“杀死应用程序”。)

It finishes the activity that was on-screen when the user pressed the BACK button.

(当用户按下“返回”按钮时,它将完成屏幕上的活动。)

It should only terminate when the users wants to terminate it - never ever any other way.

(仅当用户想要终止它时才终止它-决不能以其他方式终止。)

If you can't write apps that behave like that in Android, then I think that Android can't be used for writing real apps =(

(如果您无法编写与Android一样的应用程序,那么我认为Android不能用于编写真实的应用程序=()

Then neither can Web applications.

(然后,Web应用程序也不能。)

Or WebOS , if I understand their model correctly (haven't had a chance to play with one yet).

(或WebOS ,如果我正确理解了他们的模型(还没有机会玩过)。)

In all of those, users don't "terminate" anything -- they just leave.

(在所有这些情况下,用户都不会“终止”任何东西-他们只是离开。)

iPhone is a bit different, in that it only presently allows one thing to run at a time (with a few exceptions), and so the act of leaving implies a fairly immediate termination of the app.

(iPhone有点不同,它目前仅允许一次运行一次(有一些例外情况),因此离开行为意味着该应用程序将立即终止。)

Is there a way for me to really quit the application?

(我有办法真正退出该应用程序吗?)

As everybody else told you, users (via BACK) or your code (via finish() ) can close up your currently-running activity.

(正如其他人告诉您的那样,用户(通过BACK)或您的代码(通过finish() )可以关闭您当前正在运行的活动。)

Users generally don't need anything else, for properly-written applications, any more than they need a "quit" option for using Web applications.

(用户通常不需要其他任何东西,对于编写正确的应用程序,只需要使用“退出”选项即可使用Web应用程序。)


No two application environments are the same, by definition.

(根据定义,没有两个应用程序环境是相同的。)

This means that you can see trends in environments as new ones arise and others get buried.

(这意味着您可以看到随着新环境的出现和其他环境被掩埋而引起的环境趋势。)

For example, there is a growing movement to try to eliminate the notion of the "file".

(例如,试图消除“文件”概念的运动正在发展。)

Most Web applications don't force users to think of files.

(大多数Web应用程序都不强迫用户考虑文件。)

iPhone apps typically don't force users to think of files.

(iPhone应用程序通常不会强迫用户考虑文件。)

Android apps generally don't force users to think of files.

(Android应用程序通常不会强迫用户考虑文件。)

And so on.

(等等。)

Similarly, there is a growing movement to try to eliminate the notion of "terminating" an app.

(类似地,试图消除“终止”应用程序的想法的运动也越来越多。)

Most Web applications don't force the user to log out, but rather implicitly log the user out after a period of inactivity.

(大多数Web应用程序并不强迫用户注销,而是在一段时间不活动之后隐式注销用户。)

Same thing with Android, and to a lesser extent, iPhone (and possibly WebOS).

(与Android相同,在较小程度上与iPhone(可能还有WebOS)相同。)

This requires more emphasis on application design, focusing on business goals and not sticking with an implementation model tied to a previous application environment.

(这就需要更加强调应用程序设计,关注业务目标,而不是坚持与先前的应用程序环境绑定的实现模型。)

Developers who lack the time or inclination to do this will get frustrated with newer environments that break their existing mental model.

(缺乏时间或意愿去做的开发人员会因新环境破坏了他们现有的思维模式而感到沮丧。)

This is not the fault of either environment, any more than it is the fault of a mountain for storms flowing around it rather than through it.

(这不是这两种环境的错,更不是因为山峰绕过而不是通过风暴而造成的故障。)

For example, some development environments, like Hypercard and Smalltalk, had the application and the development tools co-mingled in one setup.

(例如,某些开发环境(例如Hypercard和Smalltalk)将应用程序和开发工具混合在一个设置中。)

This concept did not catch on much, outside of language extensions to apps (eg, VBA in Excel , Lisp in AutoCAD ).

(除了应用程序的语言扩展(例如, Excel中的 VBA ,AutoCAD中的Lisp )之外,这个概念还没有引起太大的关注。)

Developers who came up with mental models that presumed the existence of development tools in the app itself, therefore, either had to change their model or limit themselves to environments where their model would hold true.

(因此,想出了心理模型的开发人员以为应用程序本身已存在开发工具,因此他们要么必须更改其模型,要么将自己限制在其模型适用的环境中。)

So, when you write:

(因此,当您编写:)

Along with other messy things I discovered, I think that developing our app for Android is not going to happen.

(连同我发现的其他混乱情况一样,我认为开发针对Android的应用程序不会发生。)

That would appear to be for the best, for you, for right now.

(目前看来,这对您来说是最好的。)

Similarly, I would counsel you against attempting to port your application to the Web, since some of the same problems you have reported with Android you will find in Web applications as well (eg, no "termination").

(同样,我建议您不要尝试将应用程序移植到Web上,因为您在Android应用程序中发现的一些相同问题也将在Web应用程序中发现(例如,没有“终止”)。)

Or, conversely, someday if you do port your app to the Web, you may find that the Web application's flow may be a better match for Android, and you can revisit an Android port at that time.

(相反,或者相反,有一天,如果您确实将应用程序移植到Web上,则可能会发现Web应用程序的流程可能更适合Android,并且您可以在那时重新访问Android端口。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...