Show version info only once on application start in Android App

前端 未结 3 1065
迷失自我
迷失自我 2021-01-15 22:34

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

相关标签:
3条回答
  • 2021-01-15 23:04

    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
            }
    
    0 讨论(0)
  • 2021-01-15 23:05

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

    0 讨论(0)
  • 2021-01-15 23:20

    A number of solutions are documented here:

    What is SharedPreferences in Android?

    0 讨论(0)
提交回复
热议问题