admin管理员组文章数量:1387380
I'm trying to understand what happens when an Activity calls for an in-app update because I've observed behavior I don't understand. I'll explain that behavior here.
I have two activities - LaunchActivity and UpdateActivity. LaunchActivity checks to see if an update is available before calling UpdateActivity. Here's how LaunchActivity checks for an update. This code is working as expected.
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
val intent = Intent(this, UpdateActivity::class.java)
startActivity(intent)
}
}
}
UpdateActivity has a button to begin the update process. Pressing that button executes this code.
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
appUpdateManager.startUpdateFlowForResult(appUpdateInfo, activityResultLauncher,
AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build())
}
}
Pressing the button in UpdateActivity launches the Play Store overlay, which downloads and installs the update then relaunches the app as expected. When the app relaunches it opens to LaunchActivity even though UpdateActivity never received an onStop() or onDestroy(). Is this expected behavior or should the app relaunched into the UpdateActivity?
It seems redundant and inefficient to have UpdateActivity as an extra step in the process, so I moved the code from UpdateActivity into LaunchActivity and deleted UpdateActivity. This launches the same update flow as expected, but some error prevents the updated app from relaunching.
Just as with UpdateActivity, in this case LaunchActivity never received onStop() or onDestroy(). There is no logcat output from my application after LaunchActivity::onPause(). And after the update, LaunchActivity::onCreate() never gets called.
What the user sees in this second case is an update completing then dropping back to the Home Screen. I think there's something special going on with an activity when it calls startUpdateFlowForResult() but I've not been able to figure out what that is. I'm hoping people here may be able to provide insight or suggestions.
本文标签: What happens to Android Activities when they perform an inapp updateStack Overflow
版权声明:本文标题:What happens to Android Activities when they perform an in-app update? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744483255a2608294.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论