我在 android 中有一个语音识别应用程序,我想将我得到的结果与我自己的字符串进行比较这是我的代码
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK)
{
ArrayList<String> matches = data.getStringArrayListExtra(
RecognizerIntent.EXTRA_RESULTS);
for(String resultString: matches)
{
if(resultString.equalsIgnoreCase("go"))
Toast.makeText(getBaseContext(), "go", Toast.LENGTH_SHORT);
else if(resultString.equalsIgnoreCase("stop"))
Toast.makeText(getBaseContext(), "stop", Toast.LENGTH_SHORT);
else if(resultString.equalsIgnoreCase("back"))
Toast.makeText(getBaseContext(), "back", Toast.LENGTH_SHORT);
else if(resultString.equalsIgnoreCase("right"))
Toast.makeText(getBaseContext(), "right", Toast.LENGTH_SHORT);
else if(resultString.equalsIgnoreCase("left"))
Toast.makeText(getBaseContext(), "left", Toast.LENGTH_SHORT);
else
Toast.makeText(getBaseContext(), "wrong command use go , stop , back , right or left", Toast.LENGTH_SHORT);
}
}
我也尝试过使用matches.contains("go");
,即使这似乎不起作用。请帮我