为什么不保留的Andr​​oid之后pressing Home按钮的应用程序的状态,如果应用程序从应用程序管理器运行第一Tyme的? [英] Why does not Android retain application state after pressing Home button if application is ran first tyme from App Manager?

查看:199
本文介绍了为什么不保留的Andr​​oid之后pressing Home按钮的应用程序的状态,如果应用程序从应用程序管理器运行第一Tyme的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 步骤来重现问题。

  • Steps to reproduce the problem.

  1. 创建或下载中心的任何应用程序的一些活动。
  2. 加载apk文件到SD卡或者从市场安装。
  3. 在使用标准的应用程序管理器安装appliaction。
  4. 在安装在通知消息应用程序管理器preSS打开或preSS后下载后。
  5. 在运行的应用程序进入下一个(第二)应用程序界面。
  6. preSS HOME。
  7. preSS应用程序图标。

发生了什么事。

Appliaction从第一屏重启,而且不保留第二个屏幕。 应用程序保留在正常的方式activites后重新启动应用程序,或者如果你回到pressing按钮,在应用程序主屏幕。

Appliaction is restarting from the first screen and does not retain the second screen. Application retains activites in normal way after application restart or if you pressing BACK button in application to home screen.

  • 在正确的行为应该是。

应用程序必须始终保持activites以正常的方式。

Application must always retain activites in normal way.

我该如何解决这个问题我的应用程序? 我可以先运行过程中重新启动应用程序?

How can I solve this problem for my application? Can I restart application during first run?

推荐答案

根据应用程序是如何在清单文件中定义的,以及是否有任何机制来保存和恢复它的状态......

Depending on how the application is defined in the manifest file and whether it has any mechanism to save and restore its state....

根据你的脚步,它可能会造成同一应用程序的多个实例(检查的这个

Based on your steps, it might create several instances of the same application (check this)

或者,它是不使用实例Bunble在<一href="http://developer.android.com/reference/android/app/Activity.html#onCreate%28android.os.Bundle%29"相对=nofollow>的onCreate

Or it is not using the instance Bunble in onCreate

这绝对不会是自动适用于所有应用回来的保存画面是在它被暂停或销毁时(某些应用不希望出现这种情况,想想你的银行账户管理...)

It is definitely not going to be automatic for all applications to come back to the save screen it was at when it was paused or destroyed (some application do not want that, think about your bank account management...)

修改

所以,如果我从你的意见正确认识,它可以作为你希望当您退出与返回键的应用程序,而不是当您使用HOME键...

So if I understand correctly from your comments, it works as you expect when you quit the application with the BACK key, but not when you use the HOME key...

阅读我张贴的链接:的http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html

您会明白,当你preSS HOME键,您的应用程序的情况下,你是在不被破坏(因此当前的状态不会被保存)。再次启动只是启动另一个实例(从初始屏幕)。

You will understand that when you press the HOME key, the instance of your application you were in is not destroyed (and so the current state is not saved). Starting it again only starts another instance (from the initial screen).

当用户presses BACK键,   当前活动被破坏并   在previous活动恢复。

When the user presses the BACK key, the current activity is destroyed and the previous activity resumes.

...

一个任务是一个有机的整体,可   移动到后台,当用户   开始一个新的任务或进入主页   屏幕上,通过HOME键

A task is a cohesive unit that can move to the "background" when users begin a new task or go to the Home screen, via the HOME key

如果你想改变它的行为方式,看 launchMode 在清单中。

If you want to change the way it behaves, look at the launchMode in the manifest.

这篇关于为什么不保留的Andr​​oid之后pressing Home按钮的应用程序的状态,如果应用程序从应用程序管理器运行第一Tyme的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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