如何在android小部件中实现语音识别?

如何在android小部件中实现语音识别?,android,android-intent,widget,android-widget,voice-recognition,Android,Android Intent,Widget,Android Widget,Voice Recognition,可以在小部件中引入语音识别吗 我的问题是一个小部件从AppWidgetProvider扩展而来,我不能使用onActivityResult方法,所以我不知道如何获得Intent的结果 Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUA

可以在小部件中引入语音识别吗

我的问题是一个小部件从AppWidgetProvider扩展而来,我不能使用onActivityResult方法,所以我不知道如何获得Intent的结果

Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say something");

PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0, voiceIntent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.voice_widget);
views.setOnClickPendingIntent(R.id.wid, pendingIntent2);

appWidgetManager.updateAppWidget( appWidgetId, views );

可能重复“是”,您可以使用SpeechRecognizer API并通过Listener获得结果。你知道我在哪里可以找到使用SpeechRecognitor API的好教程吗?