0
我試圖創建一個應用程序,當一個電話打到電話,呼叫必須根據用戶語音命令自動出席或結束。在這裏,我給我所嘗試的,我得到錯誤在startVoiceRecognitionActivity()方法像活動未發現異常:找不到處理意圖的活動。在android不工作的語音識別
public void startVoiceRecognitionActivity()
{
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) {
// TODO Auto-generated method stub
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK)
{
String spch = data.getStringExtra(RecognizerIntent.EXTRA_RESULTS);
if (spch.contains("Yes"))
{
enableSpeakerPhone(this);
Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_HEADSETHOOK);
i.putExtra(Intent.EXTRA_KEY_EVENT, event);
this.sendOrderedBroadcast(i, null);
}
else if(spch.contains("No"))
{
Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
this.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}
}
super.onActivityResult(requestCode, resultCode, data);
}
誰能幫我找出問題...
你是否有機會在模擬器上進行測試? – 2013-03-25 12:25:04
發佈你的logcat。 – 2013-03-25 15:28:14