Android RecognizerIntent Speech recognition returns RESULT_CLIENT_ERROR

送分小仙女□ 提交于 2020-01-17 12:38:28

问题


I have implemented search view using Leanback Search Fragment in Android TV App. It works fine for the keyboard input text. But the voice search returns RESULT_CLIENT_ERROR 99%. However the text appears in the edit text on the screen but does not return in onActivityResult. Once in a bluemoon I get RESULT_OK with correct data in the intent. Device: Nexus Player

Even the default search works the same way most of the items. Hardly do i get the results via voice. (Search in home screen of nexus player i mean)

I try to get the text using the reference of the SearchEditText no luck but.

The following is the code:

  setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
      @Override
      public void recognizeSpeech() {
          try {
              startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
          } catch (final ActivityNotFoundException e) {
              Log.d("ActivityNotFoundException",e.toString());
          }
      }
  });

onActivityResult

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
        case REQUEST_SPEECH:
            switch (resultCode) {
                case Activity.RESULT_OK:
                    setSearchQuery(data, true);
                    break;
                case RecognizerIntent.RESULT_CLIENT_ERROR:
                    Log.d("RESULT_CLIENT_ERROR", String.valueOf(requestCode));
                    break;
            }
    }
}

How do i make it work 100% Is there anything I can change in the intent provided?


回答1:


This is a problem with Nexus player as even the default search operation of the Nexus Player behaves the same way.

However the same piece of code works 100% fine on Sony Bravia and other Android TVs.



来源:https://stackoverflow.com/questions/33095771/android-recognizerintent-speech-recognition-returns-result-client-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!