简体   繁体   English

应用更新后,活动生命周期会怎样?

[英]What happens to the Activity lifecycle after an app update?

Suppose this scenario. 假设这种情况。 You have an app where you fill a form in one activity. 您有一个应用程序,可以在一个活动中填写表格。 The activity uses onRestoreInstanceState and onSaveInstanceState to save the responses of the form. 该活动使用onRestoreInstanceStateonSaveInstanceState来保存表单的响应。 If a user is filling the form with app version 1, and then the PlayStore automatically updates and installs the app to version 2 before he finishes, what version was the form completed on? 如果用户使用应用程序版本1填写表单,然后PlayStore在完成之前自动将应用程序更新并安装到版本2,那么该表单是在哪个版本上完成的?

Same question but supposing the user forces the update? 同样的问题,但假设用户强制更新?

Thanks 谢谢

The app update is a process involving the apk currently stored on your device and the updated apk from PlayStore. 应用更新是一个过程,涉及当前存储在设备上的apk和PlayStore中更新的apk。 To apply the update, the system will kill your application. 要应用更新,系统将终止您的应用程序。

Originally(before API21), the bundle containing the InstanceState was valid only if the app was opened, but after API21 you can set the persistableMode true, so your bundle will survive to process kill and will be available in your onCreate(Bundle, PersistableBundle) method as second parameter. 最初(在API21之前),包含InstanceState的捆绑包仅在打开应用程序后才有效,但是在API21之后,您可以将persistableMode设置为true,因此您的捆绑包将幸免于死,并将在onCreate(Bundle, PersistableBundle)可用方法作为第二个参数。

生命周期将与关闭和打开应用程序相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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