Show version info only once on application start in Android App(在 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 中的应用程序启动时仅显示一次版本信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android App 中的应用程序启动时仅显示一次版本信息


- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01