React 配置化+Serverless 开发个人博客MK

224 阅读1分钟

download:React 配置化+Serverless 开发个人博客

import org.json.JSONArray;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
public class PluginTest extends Plugin {   public static String ACTION = "hello";
    public PluginTest() {
    }
    /**
     * Executes the request and returns PluginResult.
     *
     * @param action         The action to execute.
     * @param args             JSONArray of arguments for the plugin.
     * @param callbackId    The callback id used when calling back into JavaScript.
     * @return                 A PluginResult object with a status and message.
     */
    @Override
    public PluginResult execute(String action, JSONArray args, String callbackId) {
        try {
            JSONObject jsonObj = new JSONObject();//能够返回给JS的JSON数据
            if (action.equals("hello")) {
                String str1= args.getString(0); //获取第一个参数
                String str2= args.getString(1); //获取第二个参数
                jsonObj.put("str1", str1+"1");  //把参数放到JSONObject对象中
                jsonObj.put("str2", str2+"2");  //把参数放到JSONObject对象中
            }
            PluginResult r = new PluginResult(PluginResult.Status.OK,jsonObj);
            return r;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }