OCRTest/src/main/java/edu/sfsu/cs/orange/ocr/CaptureActivity.java
private boolean checkFirstLaunch() {
    try {
      PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
      int currentVersion = info.versionCode;
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      int lastVersion = prefs.getInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, 0);
        isFirstLaunch = lastVersion == 0;
      if (currentVersion > lastVersion) {

        // Record the last version for which we last displayed the What's New (Help) page
        prefs.edit()
                .putInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, currentVersion)
                .apply();
        Intent intent = new Intent(this, HelpActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

        // Show the default page on a clean install, and the what's new page on an upgrade.
        String page = lastVersion == 0 ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE;
        intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page);
        startActivity(intent);
        return true;
      }
    } catch (PackageManager.NameNotFoundException e) {
      Log.w(TAG, e);
    }
    return false;
  }
/**
   * We want the help screen to be shown automatically the first time a new version of the app is
   * run. The easiest way to do this is to check android:versionCode from the manifest, and compare
   * it to a value stored as a preference.
   */
We want the help screen to be shown automatically the first time a new version of the app is
run. The easiest way to do this is to check android:versionCode from the manifest, and compare
it to a value stored as a preference.
We want the help screen to be shown automatically the first time a new version of the app is run . The easiest way to do this is to check android : versionCode from the manifest and compare it to a value stored as a preference .
private boolean checkFirstLaunch() {
    try {
      PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
      int currentVersion = info.versionCode;
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      int lastVersion = prefs.getInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, 0);
        isFirstLaunch = lastVersion == 0;
      if (currentVersion > lastVersion) {
        prefs.edit()
                .putInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, currentVersion)
                .apply();
        Intent intent = new Intent(this, HelpActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        String page = lastVersion == 0 ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE;
        intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page);
        startActivity(intent);
        return true;
      }
    } catch (PackageManager.NameNotFoundException e) {
      Log.w(TAG, e);
    }
    return false;
  }
private boolean checkFirstLaunch ( ) { try { PackageInfo info = getPackageManager ( ) . getPackageInfo ( getPackageName ( ) , 0 ) ; int currentVersion = info . versionCode ; SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( this ) ; int lastVersion = prefs . getInt ( PreferencesActivity . KEY_HELP_VERSION_SHOWN , 0 ) ; isFirstLaunch = lastVersion == 0 ; if ( currentVersion > lastVersion ) { prefs . edit ( ) . putInt ( PreferencesActivity . KEY_HELP_VERSION_SHOWN , currentVersion ) . apply ( ) ; Intent intent = new Intent ( this , HelpActivity . class ) ; intent . addFlags ( Intent . FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET ) ; String page = lastVersion == 0 ? HelpActivity . DEFAULT_PAGE : HelpActivity . WHATS_NEW_PAGE ; intent . putExtra ( HelpActivity . REQUESTED_PAGE_KEY , page ) ; startActivity ( intent ) ; return true ; } } catch ( PackageManager . NameNotFoundException e ) { Log . w ( TAG , e ) ; } return false ; }
We want the help screen to be shown automatically the first time a new version of the app is
 run.
We want the help screen to be shown automatically the first time a new version of the app is run .
// Record the last version for which we last displayed the What's New (Help) page
 // Show the default page on a clean install, and the what's new page on an upgrade.
