Advertisements

Check for Update

 private void checkForUpdate() {
    int latestAppVersion = (int) mFirebaseRemoteConfig.getDouble(VERSION_CODE_KEY);
    if (latestAppVersion > getCurrentVersionCode()) {
      new AlertDialog.Builder(this).setTitle("Please Update the App")
          .setMessage("A new version of this app is available. Please update it").setPositiveButton(
          "OK", new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              Toast
                  .makeText(MainActivity.this, "Take user to Google Play Store", Toast.LENGTH_SHORT)
                  .show();
            }
          }).setCancelable(false).show();
    } else {
      Toast.makeText(this,"This app is already upto date", Toast.LENGTH_SHORT).show();
    }
  }