gpt4 book ai didi

android - 如何检测android应用程序何时升级?

转载 作者:行者123 更新时间:2023-12-03 09:09:33 25 4
gpt4 key购买 nike

检测 Android 应用程序何时升级的最佳方法是什么?是否有回调?

最佳答案

使用

import com.yourpackage.BuildConfig;
...
int versionCode = BuildConfig.VERSION_CODE;

当您的应用程序启动时,请检查 SQLite 数据库或 SharedPreferences 中的版本号,如果不存在或版本号较低,则应用程序已更新并存储新版本号。每次启动时检查当前版本代码是否高于存储的版本代码。

来自https://developer.android.com/guide/topics/manifest/manifest-element.html

android:versionCode

An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute.The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number....

关于android - 如何检测android应用程序何时升级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43909765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com