我想从音频中识别声音。它将显示识别的单词列表视图。我写了一个代码来执行这项工作,但得到一个致命的异常“android.content.ActivityNotFoundException”。
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tView=(TextView) findViewById(R.id.Textshow);
vButton=(Button) findViewById(R.id.speakButton);
lView=(ListView) findViewById(R.id.listView);
vButton.setOnClickListener(this);
}
@Override
public void onClick(View arg0)
{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo...");
startActivityForResult(intent, REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode==REQUEST_CODE && resultCode==RESULT_OK)
{
ArrayList<String> result=data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
lView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,result));
}
super.onActivityResult(requestCode, resultCode, data);
}
这种异常的原因是什么?我该如何解决?谢谢。