A Simple Extension

Could someone provide here a source code for a simple extension for ide.makeroid.io ?

Something very simple, send 2 numbers and return the result.

Thank you in advance.

Another Greek:’)

9 Likes

thanks @pavi2410 but I couldn’t manage to finish it. The following is a copy of yours with some modifications in order to pass the compilation.

Differences are on the

  • import packages (not important, the same packages you import in a higher level)
  • the return value of methods (I got a syntax error when return a+b; so I used return a; just to pass compiler error)

The .aix file is compiled successfully. My problem is when I import the .aix into a project, I can’t find the methods Add, Sub

package io.makeroid.xxxxxxxxxx.SimpleMaths;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;

@DesignerComponent(
version = 1,
description = “Extension made with Makeroid IDE”,
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = “https://ide.makeroid.io/assets/logo.png”)

@SimpleObject(external = true)
public final class SimpleMaths extends AndroidNonvisibleComponent {

/**

  • Creates a new component
    */
    public SimpleMaths(ComponentContainer container) {
    super(container.$form());
    }
@SimpleFunction(description = "Simple addition of two numbers")
public double Add(double a, double b) {
    return a;
}

@SimpleFunction(description = "Simple sub of two numbers")
public double Sub(double a, double b) {
    return b;
}

}

edit:
Everything is ok except the syntax error I get when the line is return a+b; or return a-b;
Thanks again.

Someone else already reported that the + sign crashes the extension, I’ll take a look :+1:

2 Likes

I’ve just pushed an update which should fix the “+” sign (@Vasques1995)

Please test it again (remember to wait a few hours as cache will be there for a while, not only client side, also server side)

2 Likes

Yes, the +,- signs work fine now.
Thanks a lot :slight_smile:

3 Likes

2 posts were split to a new topic: How to write a OnButtonClick in a extension?

This post was flagged by the community and is temporarily hidden.