在 Android App 中的应用程序启动时仅显示一次版本信息 [英] Show version info only once on application start in Android App

查看:29
本文介绍了在 Android App 中的应用程序启动时仅显示一次版本信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个带有确定按钮的简单信息对话框,关于此版本中的新功能,但它应该只在第一次启动时显示.实现这一点的最佳方法是什么?

I´d like to show a simple information dialog with an Ok-Button, about whats new in this version, but it should show only at the first start. Whats the best way to implement this ?

推荐答案

我会(并且已经)使用带有 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
        }

这篇关于在 Android App 中的应用程序启动时仅显示一次版本信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆