简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM