问题描述
我想与OK-Button一起显示一个简单的信息对话框,以了解此版本中的新事物,但它只能在第一个开始时显示.实施此功能的最佳方法是什么?
推荐答案
i将(并且已经)使用带有布尔值或int值的共享流程.只需检查最后一个版本是否比当前版本更古老,然后更新INT. 这是一个不错的小狙击.
//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 }
其他推荐答案
这里记录了许多解决方案:
其他推荐答案
用布尔值存储在某个地方的布尔变量:首选项,db,sd卡,..
问题描述
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 }
其他推荐答案
A number of solutions are documented here:
What is SharedPreferences in Android?
其他推荐答案
with a boolean variable stored somewhere : preferences, DB, SD card, ..