日期:2014-05-16 浏览次数:20365 次
PhoneGap.exec = function(success, fail, service, action, args) PhoneGap.callbackSuccess = function(callbackId, args) PhoneGap.callbackError = function(callbackId, args)
var exec = require("cordova/exec"); exec(successCallback, errorCallback, "Accelerometer","getAcceleration", []);
var r = prompt(JSON.stringify(args), "gap:"+ JSON.stringify([service,action,callbackId, true]));
//所在函数 org.apache.cordova.CordovaChromeClient.onJsPrompt if (reqOk && defaultValue != null && defaultValue.length() > 3 && defaultValue.substring(0, 4).equals("gap:")) { JSONArray array; try { array = new JSONArray(defaultValue.substring(4)); String service = array.getString(0); String action = array.getString(1); String callbackId = array.getString(2); boolean async = array.getBoolean(3); String r = ctx.pluginManager.exec(service, action, callbackId, message, async); result.confirm(r); } catch (JSONException e) { e.printStackTrace(); } }
// line 757 成功返回处理 if (v.status === cordova.callbackStatus.OK) { if (success) { try { success(v.message); } catch (e) { console.log("Error in success callback: " + callbackId + " = " + e); } if (!v.keepCallback) { delete cordova.callbacks[callbackId]; } } return v.message; } // line 788 失败处理 else { if (fail) { try { fail(v.message); } catch (e1) { console.log("Error in error callback: " + callbackId + " = " + e1); } if (!v.keepCallback) { delete cordova.callbacks[callbackId]; } } return null; }
var callbackId = service + cordova.callbackId++; if (success || fail) { cordova.callbacks[callbackId] = { success : success, fail : fail }; }
//line 157 org.apache.cordova.api.Plugin public void success(PluginResult pluginResult, String callbackId) { this.ctx.sendJavascript(pluginResult.toSuccessCallbackString(callbackId)); } //line 86 org.apache.cordova.api.PluginResult public String toSuccessCallbackString(String callbackId) { return "require('cordova').callbackSuccess('"+callbackId+"',"+this.getJSONString()+");"; }
// line 81 org.apache.cordova.GeoListener.success void success(Location loc) { String params = loc.getLatitude() + "," + loc.getLongitude() + ", " + loc.getAltitude() + "," + loc.getAccuracy() + "," + loc.getBearing() + "," + loc.getSpeed() + "," + loc.getTime(); if (id == "global") { this.stop(); } this.broker.sendJavascript("navigator._geo.success('" + id + "'," + params + ");"); }