且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Android App 中的应用程序启动时仅显示一次版本信息

更新时间:2023-10-20 20:45:58

我会(并且已经)使用带有 boolean 或 int 值的 SharedPreferences.只需检查最后一个版本是否比当前版本旧并更新 int.这是一个不错的小片段.

I would (and have) used a SharedPreferences with a boolean or int value. Simply check if the last version is older than the current version and update the int. Here's a nice little snipit.

//check to see if we need to show whats new or not
        SharedPreferences config = getSharedPreferences(MY_PREFS_STRING, 0);
        int lastVersion = config.getInt(KEY_VERSION, -1);
        if(currentVersion > lastVersion ){
showDialog(id);
//set this as lastVersion
        }