[英]Android application not restoring state when installed from .apk, works fine from eclipse
This is very strange: when I test my app installed from Eclipse, it is restoring it's state just fine, eg it shows the correct activity/ screen after moving away from the app and then tapping the icon again. 这很奇怪:当我测试从Eclipse安装的应用程序时,它正在恢复其状态,例如,离开应用程序并再次点击图标后,它会显示正确的活动/屏幕。 This does not work when I install the exact same code from an exported .apk file: the app comes back "blank", starting with the login screen. 当我从导出的.apk文件安装完全相同的代码时,这将不起作用:从登录屏幕开始,该应用程序返回“空白”。
What could be the reason for this? 这可能是什么原因?
When you click "run" button in Eclipse it does not means that application is really installed. 当您在Eclipse中单击“运行”按钮时,这并不意味着该应用程序已真正安装。 It may just returns to screen in last state. 它可能只是返回到最后状态的屏幕。 This happens when you do not make any changes in code since last run. 自上次运行以来未对代码进行任何更改时,会发生这种情况。
When you really install app (by eclipse / from apk / by adb) android first stops already running old app, then reinstall it and runs from very beginning (login screen in your case). 当您真正安装应用程序时(通过eclipse /从apk /通过adb),android首先停止已在运行的旧应用程序,然后重新安装并从头开始运行(以您的情况为登录屏幕)。 It is valid behavior and you can not change it. 这是有效的行为,您无法更改。
If you have some data (eg logins or passwords), that should be saved through installs or updates you should use backup servie . 如果您有一些数据(例如登录名或密码),应通过安装或更新保存这些数据,则应使用备份服务 。 It will work even if you install app to another device. 即使您将应用程序安装到其他设备,它也将起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.