Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用BroadcastReceiver intent查询SpeechReceignizer支持的语言_Android_Broadcastreceiver_Speech Recognition - Fatal编程技术网

Android 使用BroadcastReceiver intent查询SpeechReceignizer支持的语言

Android 使用BroadcastReceiver intent查询SpeechReceignizer支持的语言,android,broadcastreceiver,speech-recognition,Android,Broadcastreceiver,Speech Recognition,使用SpeechRecognitor.ACTION\u GET\u supported\u languages查询支持的语言时遇到问题 private void queryLanguages() { Intent i = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); sendOrderedBroadcast(i, null); } 现在,我知道它说BroadcastReceiver是在RecognizerIn

使用SpeechRecognitor.ACTION\u GET\u supported\u languages查询支持的语言时遇到问题

private void queryLanguages() {
    Intent i = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
    sendOrderedBroadcast(i, null);
}
现在,我知道它说BroadcastReceiver是在RecognizerIntent.DETAILS_META_DATA中指定的,但我不确定如何访问它


因此,基本上我要问的是如何创建检索可用语言数据的意图?

这是如何做到的:

    Intent intent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
    context.sendOrderedBroadcast(intent, null, new HintReceiver(),
                    null, Activity.RESULT_OK, null, null);

私有静态类HintReceiver扩展了BroadcastReceiver{
@凌驾
公共void onReceive(上下文、意图){
中频(DBG)
Log.d(标记“onReceive”(+intent.toUri(0)+”);
如果(getResultCode()!=活动。结果\u确定){
返回;
}
//支持的语言列表。
ArrayList提示=GetResultTextRas(true)
.getCharSequenceArrayList(
RecognizerIntent.EXTRA_支持的_语言);
}
}
注:

是否实际提供这些功能取决于特定的实现


我很感激代码!看起来现在有更多的语言,甚至是拉丁语!英雄联盟
    private static class HintReceiver extends BroadcastReceiver {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (DBG)
                    Log.d(TAG, "onReceive(" + intent.toUri(0) + ")");
                if (getResultCode() != Activity.RESULT_OK) {
                    return;
                }
                // the list of supported languages. 
                ArrayList<CharSequence> hints = getResultExtras(true)
                        .getCharSequenceArrayList(
                                RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);

        }
    }