private void attemptDecrypt() {
    mPlaintextView.setError(null);
    mPlaintextView.setText("");
    mCiphertextView.setError(null);

    try {
      byte[] ciphertext = base64Decode(mCiphertextView.getText().toString());
      byte[] associatedData =
          mAssociatedDataView.getText().toString().getBytes(StandardCharsets.UTF_8);
      byte[] plaintext = mApplication.aead.decrypt(ciphertext, associatedData);
      mPlaintextView.setText(new String(plaintext, StandardCharsets.UTF_8));
    } catch (GeneralSecurityException | IllegalArgumentException e) {
      mPlaintextView.setError(
          String.format("%s: %s", getString(R.string.error_cannot_decrypt), e.toString()));
      mCiphertextView.requestFocus();
    }
  }
This activity allows users to encrypt and decrypt a string.
java_src/examples/android/helloworld/app/src/main/java/com/helloworld/MainActivity.java