@SuppressWarnings("deprecation") // TODO: refactor to use DialogFrament
    @Override
    public void onClick(View v) {
      int position = findAccountPositionInList();
      if (position == -1) {
        throw new RuntimeException("Account not in list: " + account);
      }

      try {
        computeAndDisplayPin(account.getIndex(), position, true);
      } catch (OtpSourceException e) {
        throw new RuntimeException("Failed to generate OTP for account", e);
      }

      final String pin = account.getPin();

      // Temporarily disable code generation for this account
      account.setIsHotpCodeGenerationAllowed(false);
      userAdapter.notifyDataSetChanged();
      // The delayed operation below will be invoked once code generation is yet again allowed for
      // this account. The delay is in wall clock time (monotonically increasing) and is thus not
      // susceptible to system time jumps.
      handler.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              account.setIsHotpCodeGenerationAllowed(true);
              userAdapter.notifyDataSetChanged();
            }
          },
          HOTP_MIN_TIME_INTERVAL_BETWEEN_CODES);
      // The delayed operation below will hide this OTP to prevent the user from seeing this OTP
      // long after it's been generated (and thus hopefully used).
      handler.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              if (!pin.equals(account.getPin())) {
                return;
              }
              account.setPin(getString(R.string.empty_pin));
              userAdapter.notifyDataSetChanged();
            }
          },
          HOTP_DISPLAY_TIMEOUT);
    }
Listener for the Button that generates the next OTP value.
java/com/google/android/apps/authenticator/AuthenticatorActivity.java