誰かがこれで私を助けることができます:これは私のコードです:
// 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フォンギャップ
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を提供します。なんで?わからないけど、誰か助けてくれませんか?どうもありがとうございます!