Skip to content
Permalink
Browse files
fix(android): Avoid Crash Report: ConcurrentModificationException (#1073
)

Authored-by: lempere <lempere@lempere.com>
  • Loading branch information
lempere committed Mar 28, 2021
1 parent 19a5feb commit f927014d065ac63225a67054da85cfebfe808d71
Showing 1 changed file with 14 additions and 5 deletions.
@@ -30,6 +30,7 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.net.Uri;
import android.os.Bundle;
import android.os.Debug;
import android.os.Build;

/**
* PluginManager is exposed to JavaScript in the Cordova WebView.
@@ -331,11 +332,19 @@ public void onDestroy() {
public Object postMessage(String id, Object data) {
LOG.d(TAG, "postMessage: " + id);
synchronized (this.pluginMap) {
for (CordovaPlugin plugin : this.pluginMap.values()) {
if (plugin != null) {
Object obj = plugin.onMessage(id, data);
if (obj != null) {
return obj;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
this.pluginMap.forEach((s, plugin) -> {
if (plugin != null) {
plugin.onMessage(id, data);
}
});
} else {
for (CordovaPlugin plugin : this.pluginMap.values()) {
if (plugin != null) {
Object obj = plugin.onMessage(id, data);
if (obj != null) {
return obj;
}
}
}
}

0 comments on commit f927014

Please sign in to comment.