title: Android app crashes when EditText is blank and button pressed
body: <pre><code>package com.davidcleary.numberguesser;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.Toast;
  import java.util.Random;
  
  public class MainActivity extends AppCompatActivity {
  
  int randomNumber;
  Random randNum = new Random();
  
  public void randomGenerator(View view) {
  
      boolean isRight = false;
  
      EditText guess = (EditText) findViewById(R.id.guessText);
      String myGuess = guess.getText().toString();
  
      int guessInt = new Integer(guess.getText().toString());
  
          if (guess.getText().toString().equals("")) {
  
              Toast.makeText(getApplicationContext(), "Please Enter A Guess!", Toast.LENGTH_SHORT).show();
  
          } else if (guessInt == randomNumber) {
  
              Toast.makeText(getApplicationContext(), "You Guessed The Right Number!!! " + "( " + guessInt + " )", Toast.LENGTH_LONG).show();
              guess.setText("");
              randomNumber = randNum.nextInt(21);
  
          } else if (guessInt &gt; randomNumber) {
  
              Toast.makeText(getApplicationContext(), "Your Guess Is Too High! " + "( " + guessInt + " )", Toast.LENGTH_SHORT).show();
              guess.setText("");
  
  
          } else {
  
              Toast.makeText(getApplicationContext(), "Your Guess Is Too Low! " + "( " + guessInt + " )", Toast.LENGTH_SHORT).show();
              guess.setText("");
  
  
          }
      }
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      randomNumber = randNum.nextInt(21);
  
     }
  }
  </code></pre>
  
  <p>My app is crashing when i press the 'guess' button on my app even though I have the line </p>
  
  <pre><code>if (guess.getText().toString().equals("")) {
  
              Toast.makeText(getApplicationContext(), "Please Enter A Guess!", Toast.LENGTH_SHORT).show();
  
          } 
  </code></pre>
  
  <p>to try and catch the empty EditText.</p>
  
  <p>I  have looked at other stackOverflow posts but none could solve my error.</p>
  
  <p>Here is the logcat:</p>
  
  <pre><code>02-24 20:35:10.645 15999-15999/? I/art: Late-enabling -Xcheck:jni
  02-24 20:35:10.683 15999-15999/com.davidcleary.numberguesser            W/ResourceType: Found multiple library tables, ignoring...
  02-24 20:35:10.784 15999-16028/com.davidcleary.numberguesser     D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
  02-24 20:35:10.790 15999-15999/com.davidcleary.numberguesser D/Atlas:    Validating map...
  02-24 20:35:10.849 15999-16028/com.davidcleary.numberguesser I/Adreno-  EGL: &lt;qeglDrvAPI_eglInitialize:410&gt;: EGL 1.4 QUALCOMM build:   AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030_msm8974_LA.BF.1.1.1_RB1__    release_AU ()
                                                                             OpenGL ES Shader Compiler Version: E031.25.03.06
                                                                            Build Date: 07/13/15 Mon
                                                                            Local Branch: mybranch11906725
                                                                           Remote Branch: quic/LA.BF.1.1.1_rb1.26
                                                                          Local Patches: NONE
                                                                          Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030 +  6151be1 + a1e0343 + 002d7d6 + 7d0e3f7 +  NOTHING
  02-24 20:35:10.850 15999-16028/com.davidcleary.numberguesser    I/OpenGLRenderer: Initialized EGL, version 1.4
  02-24 20:35:10.866 15999-16028/com.davidcleary.numberguesser    D/OpenGLRenderer: Enabling debug mode 0
  02-24 20:35:10.937 15999-15999/com.davidcleary.numberguesser   I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@23edbb88    time:9305943
  02-24 20:35:14.498 15999-15999/com.davidcleary.numberguesser     D/AndroidRuntime: Shutting down VM
  02-24 20:35:14.501 15999-15999/com.davidcleary.numberguesser     E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                 Process: com.davidcleary.numberguesser, PID: 15999
                                                                                 java.lang.IllegalStateException: Could not execute method for     android:onClick
                                                                                      at     android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClic     k(AppCompatViewInflater.java:275)
                                                                                     at android.view.View.performClick(View.java:4856)
                                                                                       at android.view.View$PerformClick.run(View.java:19956)
                                                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                 at android.os.Looper.loop(Looper.java:211)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5373)
                                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                                 at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
                                                                              Caused by: java.lang.reflect.InvocationTargetException
                                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                                 at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                 at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:270)
                                                                                 at android.view.View.performClick(View.java:4856) 
                                                                                 at android.view.View$PerformClick.run(View.java:19956) 
                                                                                 at android.os.Handler.handleCallback(Handler.java:739) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                                 at android.os.Looper.loop(Looper.java:211) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5373) 
                                                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                                                 at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) 
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) 
                                                                              Caused by: java.lang.NumberFormatException: Invalid int: ""
                                                                                 at java.lang.Integer.invalidInt(Integer.java:138)
                                                                                 at java.lang.Integer.parseInt(Integer.java:358)
                                                                                 at java.lang.Integer.parseInt(Integer.java:334)
                                                                                 at java.lang.Integer.&lt;init&gt;(Integer.java:102)
                                                                                 at com.davidcleary.numberguesser.MainActivity.randomGenerator(MainActivity.java:22)
                                                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                                                 at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                 at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:270) 
                                                                                 at android.view.View.performClick(View.java:4856) 
                                                                                 at android.view.View$PerformClick.run(View.java:19956) 
                                                                                 at android.os.Handler.handleCallback(Handler.java:739) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                                 at android.os.Looper.loop(Looper.java:211) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5373) 
                                                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                                                 at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) 
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) 
  </code></pre>