Android application not restoring state when installed from .apk, works fine from eclipse

戏子无情 提交于 2019-12-11 01:55:57

问题


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. 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.

What could be the reason for this?


回答1:


When you click "run" button in Eclipse it does not means that application is really installed. 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). 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.



来源:https://stackoverflow.com/questions/11523301/android-application-not-restoring-state-when-installed-from-apk-works-fine-fro

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!