0

我正在尝试创建一个应用程序,其中当电话打来电话时,呼叫必须根据用户语音命令自动参加或结束。在这里,我给出了我尝试过的内容,我在 startVoiceRecognitionActivity() 方法中遇到错误,例如 Activity not found 异常:没有找到处理意图的活动。

   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);
}

谁能帮我找出问题...

4

1 回答 1

0

您是否在清单文件中正确声明了您的活动?

于 2013-03-25T13:09:16.013 回答