@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.check_code);

    setSupportActionBar((Toolbar) findViewById(R.id.enter_key_toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    mCodeTextView = (TextView) findViewById(R.id.code_value);
    mCheckCodeTextView = (TextView) findViewById(R.id.check_code);
    mCounterValue = (TextView) findViewById(R.id.counter_value);

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    AccountIndex index = (AccountIndex) extras.getSerializable("index");

    AccountDb accountDb = DependencyInjector.getAccountDb();
    AccountDb.OtpType type = accountDb.getType(index);
    if (type == AccountDb.OtpType.HOTP) {
      mCounterValue.setText(accountDb.getCounter(index).toString());
      findViewById(R.id.counter_area).setVisibility(View.VISIBLE);
    } else {
      findViewById(R.id.counter_area).setVisibility(View.GONE);
    }

    String secret = accountDb.getSecret(index);
    String checkCode = null;
    String errorMessage = null;
    try {
      checkCode = getCheckCode(secret);
    } catch (GeneralSecurityException e) {
      errorMessage = getString(R.string.general_security_exception);
    } catch (DecodingException e) {
      errorMessage = getString(R.string.decoding_exception);
    }
    if (errorMessage != null) {
      mCheckCodeTextView.setText(errorMessage);
      return;
    }
    mCodeTextView.setText(Utilities.getStyledPincode(checkCode));
    String checkCodeMessage = String.format(getString(R.string.check_code),
        TextUtils.htmlEncode(index.getStrippedName()));
    CharSequence styledCheckCode = Utilities.getStyledTextFromHtml(checkCodeMessage);
    mCheckCodeTextView.setText(styledCheckCode);
    mCheckCodeTextView.setVisibility(View.VISIBLE);
    findViewById(R.id.code_area).setVisibility(View.VISIBLE);

    // Show fake shadow on pre-Lollipop devices.
    if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP) {
      findViewById(R.id.toolbar_shadow).setVisibility(View.VISIBLE);
    } else {
      findViewById(R.id.toolbar_shadow).setVisibility(View.GONE);
    }
  }
Called when the activity is first created.
java/com/google/android/apps/authenticator/otp/CheckCodeActivity.java