我无法查询使用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);
}
}
请注意:
无论这些实际上是提供高达特定实施
Whether these are actually provided is up to the particular implementation