简体   繁体   English

从.apk安装后,Android应用程序无法恢复状态,从eclipse可以正常工作

[英]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.

相关问题 从Android Studio运行时,应用正常运行,但在安装签名的APK后崩溃 - App works fine when running from Android Studio but crashes when signed apk installed 直接从 Android Studio 测试时,应用程序运行良好,但在设备上作为 APK 安装时则不行 - App works fine, when testing directly from Android Studio, but not when installed as APK on the Device 从导出的 apk 安装时,应用程序因 maps.jar 文件错误而崩溃,如果我从 eclipse 安装它,则该应用程序可以正常工作 - Application crashes with error on maps.jar file when install from exported apk and works if i installed it from eclipse 如果从Android Studio构建的应用程序运行Android改造POST可以正常工作,但从APK安装时崩溃 - Android retrofit POST working fine if app built from android studio but crashes when installed from apk 从 Play 商店下载时应用程序未加载但安装生成的 APK 工作正常 - Application not loading when downloaded from Play Store but installing the generated APK works fine 从Eclipse通过Signed APK安装的Android App无法打开 - Android App installed through Signed APK from Eclipse is not opening 从 Playstore 下载时 APK 崩溃 - 调试工作正常 - APK crashing when downloading from playstore - debug works fine 通过.apk文件安装时,该应用程序被强制停止,但通过android studio中的adb安装时,该应用程序运行正常 - The app gets forced stop when installed through .apk file but works fine when installed through adb in android studio Ionic Android应用程序正常运行,但安装后无法运行 - Ionic Android app works but not apk when installed 当应用程序进程被杀死时,如何停止android恢复状态? - How to stop android from restoring state when the app process is killed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM