mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
fix(android): Avoid Crash Report: ConcurrentModificationException (#1073)
Authored-by: lempere <lempere@lempere.com>
This commit is contained in:
parent
19a5feb875
commit
f927014d06
@ -30,6 +30,7 @@ import android.content.res.Configuration;
|
||||
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 class PluginManager {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user