1 . 描述
前端Cordova .exec传入的回调无法接收到安卓端的消息
安卓端在接收到调用后, 在双层嵌套的handler里发出success消息
public void sendPluginResult(PluginResult pluginResult) {
synchronized(this) {
if (this.finished) {
Log.w("CordovaPlugin", "Attempted to send a second callback for ID: " + this.callbackId + "\nResult was: " + pluginResult.getMessage());
return;
}
this.finished = !pluginResult.getKeepCallback();
}
this.webView.sendPluginResult(pluginResult, this.callbackId);
}
3.解决
发现有cordova.exec(null,null, "gcPlugin", "log", data);
怀疑null覆盖了其他调用传入的回调函数,
修改为非空alert,
发现未调用替换的alert, 而是调用原有回调
- 原理
待续......................
网友评论