Android RecognizerIntent语音识别返回RESULT_CLIENT_ERROR [英] Android RecognizerIntent Speech recognition returns RESULT_CLIENT_ERROR

查看:192
本文介绍了Android RecognizerIntent语音识别返回RESULT_CLIENT_ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Android TV App中使用Leanback搜索片段实现了搜索视图. 它适用于键盘输入文本.但是语音搜索返回RESULT_CLIENT_ERROR 99%.但是,该文本显示在屏幕上的编辑文本中,但不会在onActivityResult中返回.进入蓝月亮后,我得到RESULT_OK并包含正确的意图数据. 设备:Nexus Player

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)

我尝试使用SearchEditText的引用获取文本,但是不走运.

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

以下是代码:

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

onActivityResult

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

我如何使它100%工作,我可以改变提供的意图吗?

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

推荐答案

这是Nexus Player的问题,因为即使Nexus Player的默认搜索操作也具有相同的作用.

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

但是,同一段代码在Sony Bravia和其他Android电视上可以100%正常工作.

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

这篇关于Android RecognizerIntent语音识别返回RESULT_CLIENT_ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆