The following code works for when the user leaves an editText of the form blank. The code worked in NetBeans but in AndroidStudio when you run the APK with a blank field it appears the message that the APP stopped working. Here is the code:
// In NetBeans
BigDecimal cota = null;
BigDecimal prazo = null;
BigDecimal reserva = null;
BigDecimal adm = null;
try {
cota = new BigDecimal(jTextField1.getText());
prazo = new BigDecimal(jTextField2.getText());
reserva = new BigDecimal(jTextField3.getText());
adm = new BigDecimal(jTextField4.getText());
} catch (NumberFormatException e) {
jLabel5.setText("Os valores não podem estar vazios!");
}
// On Android
BigDecimal cota = null;
BigDecimal prazo = null;
BigDecimal reserva = null;
BigDecimal adm = null;
BigDecimal vida = null;
try{
cota = new BigDecimal(edtCota.getText().toString());
prazo = new BigDecimal(edtPrazo.getText().toString());
reserva = new BigDecimal(edtReserva.getText().toString());
adm = new BigDecimal(edtAdm.getText().toString());
vida = new BigDecimal(edtVida.getText().toString());
}catch(NumberFormatException erro){
AlertDialog.Builder janelaVazio = new AlertDialog.Builder(Consorcio.this);
janelaVazio.setMessage("Preencha todos os campos");
janelaVazio.setNeutralButton("FECHAR", null);
janelaVazio.show();
}