本文介绍了查询中使用的BroadcastReceiver意向支持的语言为SpeechRecognizer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法查询使用SpeechRecognizer.ACTION_GET_SUPPORTED_LANGUAGES支持的语言。
I'm having trouble querying for supported languages using the SpeechRecognizer.ACTION_GET_SUPPORTED_LANGUAGES.
private void queryLanguages() {
Intent i = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(i, null);
}
现在,我知道它说的BroadcastReceiver在RecognizerIntent.DETAILS_META_DATA规定,但我不知道,我怎么能访问。
Now, I know it says the BroadcastReceiver is specified in RecognizerIntent.DETAILS_META_DATA, but I'm not sure as to how I can access that.
所以基本上我问的是如何创建一个Intent来获取可用的语言数据?
So basically what I'm asking is how do I create an Intent to retrieve the available languages data?
推荐答案
这是它是如何做:
Intent intent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
context.sendOrderedBroadcast(intent, null, new HintReceiver(),
null, Activity.RESULT_OK, null, null);
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);
}
}
请注意:
无论这些实际上是提供高达特定实施
这篇关于查询中使用的BroadcastReceiver意向支持的语言为SpeechRecognizer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!