Show version info only once on application start in Android App

走远了吗. 提交于 2020-01-21 05:59:03

问题


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 ?


回答1:


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
        }



回答2:


A number of solutions are documented here:

What is SharedPreferences in Android?




回答3:


with a boolean variable stored somewhere : preferences, DB, SD card, ..



来源:https://stackoverflow.com/questions/3612978/show-version-info-only-once-on-application-start-in-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!