是否可以在小部件中引入语音识别?
我的问题是一个小部件从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 );