@Override
  public void onCreate(Bundle savedInstanceState) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (preferences.getBoolean(AuthenticatorActivity.KEY_DARK_MODE_ENABLED, false)) {
      setTheme(R.style.AuthenticatorTheme_NoActionBar_Dark);
    } else {
      setTheme(R.style.AuthenticatorTheme_NoActionBar);
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.enter_key);

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

    // Find all the views on the page
    keyEntryField = (EditText) findViewById(R.id.key_value);
    accountName = (EditText) findViewById(R.id.account_name);
    keyEntryFieldInputLayout = (TextInputLayout) findViewById(R.id.key_value_input_layout);

    typeTotp = (RadioButton) findViewById(R.id.type_choice_totp);
    typeHotp = (RadioButton) findViewById(R.id.type_choice_hotp);

    typeTotp.setText(getResources().getStringArray(R.array.type)[OtpType.TOTP.value]);
    typeHotp.setText(getResources().getStringArray(R.array.type)[OtpType.HOTP.value]);

    keyEntryFieldInputLayout.setErrorEnabled(true);

    // Set listeners
    keyEntryField.addTextChangedListener(this);

    findViewById(R.id.add_account_button_enter_key)
        .setOnClickListener(addButtonEnterKeyOnClickListener);
  }
Called when the activity is first created
java/com/google/android/apps/authenticator/otp/EnterKeyActivity.java