I have a function that sends an email, the data that goes inside the mail are loaded by the user in the app, they are a series of fields of EditText
, now what I need to do is within this Intent.EXTRA_TEXT
condition if a field is empty at the time of sending the email, in that field nothing goes, instead if the user charges some value, that value goes; I have it this way right now
intent.putExtra(Intent.EXTRA_EMAIL, TO);
intent.putExtra(Intent.EXTRA_SUBJECT, "Relevamiento");
intent.putExtra(Intent.EXTRA_TEXT,
Html.fromHtml(new StringBuilder()
.append("<p><b>Fecha:</b>" + fecha.getText() + "</p>")
.append("<p><b>Obra:</b>" + obra.getText() + "</p>")
.append("<p><b>Ancho:</b>" + ancho2.getText() + "</p>")
.append("<p><bold>Observacion:</bold>" + obs2.getText() + "</p>")
.toString()
)
What I want to do in synthesis is; if the EditText is empty, the .append is simply ("");
if it is not empty, the .append is
("<p>Titulo del campo:" + editText.getText + "</p>").
Any ideas? Inside the EXTRA_TEXT does not let me perform a condition if
, I tried creating a separate function that does the validation, but I get an error if I have it this way:
(Intent.EXTRA_TEXT, ValidacionCampos()