I have a string array. I want to compare this string array with two string, so first i assigned array to variable then I compare this variable with strings.if array converted equals first string, do something else equals second, do something. But it raises cannot resolve method toString
error.
String stopC = "stop"; //first strıng
String fastC = "fast"; //second strıng
String userC;
switch (requestCode) {
case REQ_CODE_SPEECH_INPUT: {
if (resultCode == RESULT_OK && null != data) {
/*strıng array*/
ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
userC = Arrays.toString(result); //array convert to strıng.gıves error here.
if(userC.compareTo(fastC)==0){ //compare coverted array wth strıng
exam.speedUpBall();
Toast.makeText(this, "fast!! =)",
Toast.LENGTH_LONG).show();
}
else if (userC.compareTo(stopC)==0) {
exam.stop();
Toast.makeText(this, "stop!! =)",
Toast.LENGTH_LONG).show();
}
}
break;
}
}