title: How to compare voice command input by user to hard coded strings
body: <p>I am currently working on an app that takes user input by voice command. The program recognizes the words using the google api. I want to be able to compare the user voice input to hard coded strings. My problem is that I do not know how to code this function. I am using if else statements to match the hard coded string, but the Toast is always the wrong one. Could anyone please guide me? Thank you for your time!</p>
  
  <pre><code>/**
   * Receiving speech input
   * */
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      switch (requestCode) {
      case REQ_CODE_SPEECH_INPUT: {
          if (resultCode == RESULT_OK &amp;&amp; null != data) {
  
              ArrayList&lt;String&gt; result = data
                      .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
              txtSpeechInput.setText(result.get(0));
  
              if(txtSpeechInput.equals("weather")) {
                  Toast.makeText(getApplicationContext(), "Good", Toast.LENGTH_SHORT).show();
              }else{
  
                  Toast.makeText(getApplicationContext(), "It's a difficult question... I'm sorry", Toast.LENGTH_SHORT).show();
  
  
              }
  
          }
  
          break;
      }
  
      }
  }
  </code></pre>