1: 启动语音intent
Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);//设置启动语音的action
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");//设置语音的扫搜模式
startActivityForResult(intent, RESULT_SPEECH)//启动一个语音的intent并返回相应的结果
2:处理结果的响应语音字符串onActivityResult(int requestCode, int resultCode, Intent data)方法中处理
if (resultCode == RESULT_OK && null != data) {
ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
txtText.setText(text.get(0));
}