This time I need a One-Time PopUp in my Application, which should check the App-Version and shows the Dialog only on the first start and if a Upgrade was done (Like from Version 2.1 to 2.2).
Here is my Code:
//Pop-Up bei erstmaligem Start
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
// second argument is the default to use if the preference can't be found
Boolean welcomeScreenShown = mPrefs.getBoolean(welcomeScreenShownPref, false);
if (!welcomeScreenShown) {
//Popup Show
String whatsNewTitle = getResources().getString(R.string.whatsNewTitle);
//Changelog Text
String whatsNewText = getResources().getString(R.string.whatsNewText);
new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(whatsNewTitle).setMessage(whatsNewText).setPositiveButton(
R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(welcomeScreenShownPref, true);
editor.apply(); //Needs to be set!
}
This code works flawless, thanks to @Martyn. As I said before, there is one thing missing: A VersionCheck.
I have no idea how to get this and I hope someone could help me.