[英]Error in error callback: TestPlugin2 = ReferenceError: Can't find variable: log at file:///android_asset/www/js/cordova-1.6.1.js:276
Can somebody help me with this: this is my code: 有人可以帮我吗:这是我的代码:
//js // js
var TestPlugin={
test:function(name,successCallback,failureCallback){
console.log("navigator.service.sms smssend: ----------------");
PhoneGap.exec(successCallback, failureCallback, "TestPlugin", "test", [name]);
}};
TestPlugin.test(
"hubiao",
function(){
alert("success");
},
function(e){
alert("fail");
log(e);
}
);
//Android phonegap // Android phonegap
public class TestPlugin extends Plugin {
@Override
public PluginResult execute(String action, JSONArray data, String callBackId) {
if ("test".equalsIgnoreCase(action)) {
Log.d("DatePickerPluginListener execute", "test");
Context context=ctx.getContext();
String name="";
JSONObject fileInfo = new JSONObject();
try {
name = data.getString(0);
fileInfo.put("hello", "Android"+name);
} catch (JSONException e) {
e.printStackTrace();
}
final PluginResult r = new PluginResult(
Status.OK,fileInfo);
Log.i("TestPlugin", name);
Toast.makeText(context,"User:"+name, Toast.LENGTH_LONG).show();
return r;
}else{
Log.d("DatePickerPlugin", "Invalid action : " + action + " passed");
return new PluginResult(Status.INVALID_ACTION);
}
}
} }
/// The point: if I add: ///要点:如果我添加:
Toast.makeText(context,"User:"+name, Toast.LENGTH_LONG).show();
phonegap will give failureCallback, when I remove: 当我删除时,phonegap会给出failureCallback:
Toast.makeText(context,"User:"+name, Toast.LENGTH_LONG).show();
phonegap will give successCallback. phonegap将给予成功回调。 Why?
为什么? I have no idea.Anyone counld help me?
我不知道。有人会帮助我吗? Thank you very much!
非常感谢你!
Is this not just a simple omission of console.
这不仅仅是
console.
的简单遗漏console.
from console.log()
? 从
console.log()
?
TestPlugin.test(
"hubiao",
function(){
alert("success");
},
function(e){
alert("fail");
// log() is undefined. console.log() is defined!
console.log(e);
// Or more likely you want the error message only
console.log(e.message);
}
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.