本文介紹了在 Android App 中的應(yīng)用程序啟動(dòng)時(shí)僅顯示一次版本信息的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我想顯示一個(gè)帶有確定按鈕的簡單信息對(duì)話框,關(guān)于此版本中的新功能,但它應(yīng)該只在第一次啟動(dòng)時(shí)顯示.實(shí)現(xiàn)這一點(diǎn)的最佳方法是什么?
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 ?
推薦答案
我會(huì)(并且已經(jīng))使用帶有 boolean 或 int 值的 SharedPreferences.只需檢查最后一個(gè)版本是否比當(dāng)前版本舊并更新 int.這是一個(gè)不錯(cuò)的小片段.
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
}
這篇關(guān)于在 Android App 中的應(yīng)用程序啟動(dòng)時(shí)僅顯示一次版本信息的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!