Skip to content

Commit 14db1b4

Browse files
authored
fix(android): Send final result on partialResults listener (#66)
1 parent 3e43ac8 commit 14db1b4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

android/src/main/java/com/getcapacitor/community/speechrecognition/SpeechRecognition.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,16 @@ public void onResults(Bundle results) {
335335
try {
336336
JSArray jsArray = new JSArray(matches);
337337

338-
if (this.call != null && !this.partialResults) {
339-
this.call.resolve(
340-
new JSObject().put("status", "success").put("matches", jsArray)
341-
);
338+
if (this.call != null) {
339+
if (!this.partialResults) {
340+
this.call.resolve(
341+
new JSObject().put("status", "success").put("matches", jsArray)
342+
);
343+
} else {
344+
JSObject ret = new JSObject();
345+
ret.put("matches", jsArray);
346+
notifyListeners("partialResults", ret);
347+
}
342348
}
343349
} catch (Exception ex) {
344350
this.call.resolve(

0 commit comments

Comments
 (0)