我为 phonegap 创建了一个简单的插件,但我想将对象作为参数而不是 string 传递,下面是我的代码结构...
BackGroundService.java
public class BackGroundService extends Plugin {
public PluginResult execute(String arg0, JSONArray args, String arg2) { //How can i pass object instead or String
}
}
worker.js
var worker = function(name, win, fail) {
PhoneGap.exec(win, win, "BackGroundService", "worker", [name]);
}
PhoneGap.addConstructor(function() {
navigator.app.addService('BackGroundService','com.service.app.BackGroundService');
})
从 html 调用
worker("football", win); //Pass object instead of football
var win = function(d) {
alert("success");
}