This is my code thus far:
ArrayList<String> matches = data
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
String playString = "play";
if( matches.get(0).toString() == playString)
{
// do something
}
The voice recognition prompt pulls up just fine, and I’ve tested it and it is in fact understanding that I’m saying the word “play.” However, when doing the comparison in the if statement, it fails every time – with or without the toString(). What am I not understanding?
Instead of using
==like:if( matches.get(0).toString() == playString)Use
.equals()like:if( matches.get(0).toString().equals(playString)