title: Create dialog when there is an empty field
body: <p>I've been struggling with this problem, that keep crashing my app every time there is an empty field in it.</p>
  
  <p>when I run the code, it tells me that there is an error in the lines 32 and 37, right where I transform the string from the textView to integers to do the operations with those numbers</p>
  
  <p><a href="https://i.stack.imgur.com/gszOi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gszOi.png" alt="Error Image"></a></p>
  
  <p>It'd be great if you guys could check this out.</p>
  
  <pre><code>package com.studium.second.secondtest;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
      Activity miActividad;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          miActividad = this;
  
  
          Button calcular = findViewById(R.id.button1);
  
          calcular.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  TextView textoBase = findViewById(R.id.areaBase);
                  String base = textoBase.getText().toString();
                  int numeroBase = Integer.parseInt(base);
  
  
                  TextView textoAltura = findViewById(R.id.areaAltura);
                  String altura = textoAltura.getText().toString();
                  int numeroAltura = Integer.parseInt(altura);
  
                  //Operación
                  final TextView cajaResultado = findViewById(R.id.areaResultado);
  
                  final int operacion = numeroAltura * numeroBase;
                  cajaResultado.setText(getResources().getString(R.string.textoResultado ) + " " + operacion);
  
                  if (base == null &amp;&amp; altura != null){
                      AlertDialog.Builder builder = new AlertDialog.Builder(miActividad.getApplicationContext());
                      builder.setMessage("El parámetro base está vacío")
                              .setCancelable(false)
                              .setNegativeButton("Volver", new DialogInterface.OnClickListener() {
                                  public void onClick(DialogInterface dialog, int id) {
                                      dialog.cancel();
                                  }
                              });
                      AlertDialog alert = builder.create();
                      alert.show();
                  }
  
                  if (base != null &amp;&amp; altura == null){
                      AlertDialog.Builder builder = new AlertDialog.Builder(miActividad.getApplicationContext());
                      builder.setMessage("El parámetro altura está vacío")
                              .setCancelable(false)
                              .setNegativeButton("Volver", new DialogInterface.OnClickListener() {
                                  public void onClick(DialogInterface dialog, int id) {
                                      dialog.cancel();
                                  }
                              });
                      AlertDialog alert = builder.create();
                      alert.show();
                  }
  
  
                  if (base == null &amp;&amp; altura == null){
                      AlertDialog.Builder builder = new AlertDialog.Builder(miActividad.getApplicationContext());
                      builder.setMessage("Todos los parámetros están vacíos")
                              .setCancelable(false)
                              .setNegativeButton("Volver", new DialogInterface.OnClickListener() {
                                  public void onClick(DialogInterface dialog, int id) {
                                      dialog.cancel();
                                  }
                              });
                      AlertDialog alert = builder.create();
                      alert.show();
                  }
              }
          });
      }
  }
  </code></pre>