Can somebody help me with this: this is my code:
/日数
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);
时 时
);
/机器人电话机
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:
Toast.makeText(context,"User:"+name, Toast.LENGTH_LONG).show();
phonegap will give successCallback. Why? I have no idea.Anyone counld help me? Thank you very much!