title: Android program crashing when EditText has nothing in it
body: <p>Anybody knows how to prevent an Android application crashing when ab EditText has no value in it?</p>
  
  <p>EDIT: Sorry, I posted this with my phone. Here you go:</p>
  
  <pre><code>import java.util.Random;
  
  import android.app.Activity;
  import android.content.Context;
  import android.hardware.Sensor;
  import android.hardware.SensorEvent;
  import android.hardware.SensorEventListener;
  import android.hardware.SensorManager;
  import android.os.Bundle;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class RandomButtonActivity extends Activity implements SensorEventListener
  {
      public float x = 0, y = 0, z = 0;           
      public float a = 10, b = 10, c = 10;
      public float k = 4;
      public int j = 0, i = 0;
      public int rand = 0;
      public String j1;
      public String i1;
  
  
      TextView testo;
      TextView ultimo;
  
      EditText limiteMin;
      EditText limiteMax;
  
      Random generator = new Random();
  
      SensorManager sm;
  
      @Override
      public void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          testo = (TextView) findViewById(R.id.textView1);
          ultimo = (TextView) findViewById(R.id.textView4);
  
          limiteMin = (EditText) findViewById(R.id.editText2);
          limiteMax = (EditText) findViewById(R.id.EditText01);
  
          sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
          sm.registerListener(this, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
  
          random();
      }
  
      public void onSensorChanged(SensorEvent event)
      {
          x = event.values[0];
          y = event.values[1];
          z = event.values[2];        
  
          if(x&gt;a+k || x&lt;a-k || y&gt;b+k || y&lt;b-k || z&gt;c+k || z&lt;c-k)
          {
              rand = random();
          }
          a = x;
          b = y;
          c = z;
      }
  
      public int random() 
      {
          j = Integer.parseInt(limiteMin.getText().toString());
          i = Integer.parseInt(limiteMax.getText().toString());
          int v = 0;
  
              if(i==0 &amp;&amp; j==0)
              {
                  v = generator.nextInt();                       
              }
              else if(j&gt;=i &amp;&amp; j!=0)
              {               
                  v = 0;
              }           
              else
              {
                  i = i+1;
                  do
                  {
                  v = generator.nextInt(i);
                  testo.setText("Random: "+v);
                  }
                  while(v&lt;j);
              }
              testo.setText("Random: "+v);   
              ultimo.setText("Random precedente: "+rand);
  
          return v;
      }
  
      public void onAccuracyChanged(Sensor sensor, int accuracy) 
      {
      }
  }
  </code></pre>
  
  <p>The program crashes only when 1 of 2 EditTexts is empty and the method random() is called.</p>