private boolean validateKeyAndUpdateStatus(boolean submitting) {
    String userEnteredKey = getEnteredKey();
    try {
      byte[] decoded = Base32String.decode(userEnteredKey);
      if (decoded.length < MIN_KEY_BYTES) {
        // If the user is trying to submit a key that's too short, then
        // display a message saying it's too short.
        keyEntryFieldInputLayout.setError(
            submitting ? getString(R.string.enter_key_too_short) : null);
        return false;
      } else {
        keyEntryFieldInputLayout.setError(null);
        return true;
      }
    } catch (DecodingException e) {
      keyEntryFieldInputLayout.setError(getString(R.string.enter_key_illegal_char));
      return false;
    }
  }
Called when the activity is first created
java/com/google/android/apps/authenticator/otp/EnterKeyActivity.java