Android plugins live under:

plugins/<name>/android/com/sweetjuice/pkg/<name>/

And are synced into the template at:

AppTemplate/native/android/app/src/main/java/com/sweetjuice/pkg/<name>/

Plugin contract

Every plugin must implement SweetJuicePlugin:

public class MyPlugin implements SweetJuicePlugin {
    @Override
    public String getDomain() { return "mydomain"; }

    @Override
    public void onAttach(Context context) { }

    @Override
    public String handleAction(String action, String jsonArgsPayload) {
        // route action to handler
        return "{}";
    }
}

Action routing

handleAction receives the action name and a JSON payload. Use it to route to specific handlers:

@Override
public String handleAction(String action, String jsonArgsPayload) {
    try {
        JSONObject args = new JSONObject(jsonArgsPayload);
        switch (action) {
            case "check":
                return check(args);
            case "request":
                return request(args);
            default:
                return errorJson("Unknown action");
        }
    } catch (JSONException e) {
        return errorJson(e.getMessage());
    }
}

Returning results

Return JSON strings. The Go side receives the raw string and unmarshals it:

private String check(JSONObject args) throws JSONException {
    String permission = args.optString("permission", "");
    // ...
    JSONObject result = new JSONObject();
    result.put("status", "granted");
    return result.toString();
}