类型为Share的execute(String,JSONArray,String)方法必须覆盖或实现超类型方法

时间:2013-03-11 07:30:44

标签: cordova share phonegap-plugins

我正在使用cordova-2.4.0,当我向“src”添加“share”插件时,我收到错误“Share类型的方法execute(String,JSONArray,String)必须覆盖或实现超类型方法”。我不知道如何解决这个Java错误。我收到错误的Java文件代码是:

 /**
 * 
 * Phonegap share plugin for Android
 * Kevin Schaul 2011
 *
 */

package com.schaul.plugins.share;

import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Intent;

public class Share extends CordovaPlugin {

    @Override
    public PluginResult execute(String action, JSONArray args, String callbackId) {
        try {
            JSONObject jo = args.getJSONObject(0);
            doSendIntent(jo.getString("subject"), jo.getString("text")); 
            return new PluginResult(PluginResult.Status.OK);
        } catch (JSONException e) {
            return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
        }
    }

    private void doSendIntent(String subject, String text) {
        Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
        sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
        this.cordova.startActivityForResult(this, sendIntent, 0);
    }

}

0 个答案:

没有答案