Skip to content
This repository was archived by the owner on Oct 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.util.Log;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
Expand Down Expand Up @@ -58,7 +60,13 @@ public void onMethodCall(MethodCall call, Result result) {
case "speech.activate":
// FIXME => Dummy activation verification : we assume that speech recognition permission
// is declared in the manifest and accepted during installation ( AndroidSDK 21- )
Locale locale = activity.getResources().getConfiguration().locale;
Configuration config = activity.getResources().getConfiguration();
Locale locale;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
locale = config.getLocales().get(0);
} else {
locale = config.locale;
}
Log.d(LOG_TAG, "Current Locale : " + locale.toString());
speechChannel.invokeMethod("speech.onCurrentLocale", locale.toString());
result.success(true);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _MyAppState extends State<MyApp> {
_speech.setCurrentLocaleHandler(onCurrentLocale);
_speech.setRecognitionStartedHandler(onRecognitionStarted);
_speech.setRecognitionResultHandler(onRecognitionResult);
_speech.setRecognitionCompleteHandler(onRecognitionComplete);
_speech.setRecognitionCompleteHandler((_) => onRecognitionComplete());
_speech.setErrorHandler(errorHandler);
_speech
.activate()
Expand Down