在Android应用程序的应用开始显示版本信息只有一次 [英] Show version info only once on application start in Android App

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

问题描述

我倒是喜欢展示一个简单的信息与一个OK键式对话框,关于什么新的版本,但它应该只显示在第一次启动。最新最好的方式来实现这一点?

解决方案

我想(和有)使用的共享preferences用布尔或int值

。简单地检查最后一个版本是早于当前版本,升级INT。 这里有一个可爱的小snipit。

  //检查,看看是否需要我们表现出什么新的或不
        共享preferences配置= getShared preferences(MY_ preFS_STRING,0);
        INT lastVersion = config.getInt(KE​​Y_VERSION,-1);
        如果(CURRENTVERSION> lastVersion){
的ShowDialog(ID);
//设置此为lastVersion
        }
 

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 ?

解决方案

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应用程序的应用开始显示版本信息只有一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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