Android speech Recognition App Without Pop Up

前端 未结 4 1346
天涯浪人
天涯浪人 2020-12-02 19:30

I\'m currently looking into getting a career with JAVA and have decided to start by building an app. I have this code right here that I am using to trigger Speech Recognitio

4条回答
  •  生来不讨喜
    2020-12-02 19:52

    I ran into that issue as well. It seems like having startActivityForResult(...) will enable the pop-up mic, then you can handle the response in onActivityResult(). However, simply adding that startActivityForResult messed up my startListening(mSpeechRecognizerIntent), so you may need to do more adjustment.

    mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                                         RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
                                         this.getPackageName());
    startActivityForResult(recognizerIntent, 100);
    
    // call back
    onActivityResult(int requestCode, int resultCode, Intent data){...}
    

提交回复
热议问题