有人可以帮我这个: 这是我的代码:
// 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
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);
}
}
}
/// 重点: 如果我补充:
Toast.makeText(context,"User:"+name, Toast.LENGTH_LONG).show();
phonegap将给出failureCallback, 当我删除:
Toast.makeText(context,"User:"+name, Toast.LENGTH_LONG).show();
phonegap将给予successCallback。 为什么?我不知道。任何人都帮助我?非常感谢你!
答案 0 :(得分:0)
这不仅仅是对来自console.
的{{1}}的简单遗漏吗?
console.log()