Often, in applications after the update, a dialog box with a description of the update itself came up. In the settings menu I can display a dialog box with the necessary information using the alertdialog, but how can I make the dialog box pop up at startup? If necessary, I can provide the code

  • 2
    just in onCreate () of the first Activity, call a dialog showing, what's the problem? - Vladyslav Matviienko
  • well, by the way, it’s better not to do it in Create, there is a possibility that a heavy UI can be grabbed ex, a small probability of canes, and even if it’s not a fragment, as it is recommended to do, but still. - Shwarz Andrei

1 answer 1

Here you have a class that checks whether a dialog has been shown with new features for this version of the application and if not, then a display of it.

Just call the verification method in the main activation,

NewVersionFeachersDialog.appLaunched(this); 

And add the show of the actual dialogue to the end of the class, where // TODO

 public class NewVersionFeachersDialog { public static void appLaunched(Context ctx) { PackageManager pm = ctx.getPackageManager(); String app_ver = ""; try { app_ver = pm.getPackageInfo(ctx.getPackageName(), 0).versionName; Log.i("app_ver", app_ver); SharedPreferences prefs = ctx.getSharedPreferences(app_ver, Context.MODE_PRIVATE); if (prefs.getBoolean(ActivityPreference.PREF_KEY_FIRST_LAUNCH, false) == true) { return; } else { SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(ActivityPreference.PREF_KEY_FIRST_LAUNCH, true); editor.commit(); showNewVersionDialog(ctx); } } catch (NameNotFoundException e) { throw new AssertionError(); } } public static void showNewVersionDialog(final Context ctx) { PackageManager pm = ctx.getPackageManager(); String app_ver = ""; try { app_ver = pm.getPackageInfo(ctx.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { throw new AssertionError(); } String message = "new versionFeatures"; //заполните строку нужными данными и задайте её как текст диалогу //TODO тут отобразите диалог с вашим сообщением } } 
  • Thanks for the reply, but I’m getting something wrong - user210886