Creating Your First Extension Guide

Published on January 22, 2022

Revamped on February 5, 2023

After months of playing around with AppInventor, you already know the basics of programming with AppInventor, and now, you are ready to move on to another level. You can now learn how to create extensions, components that are not native to AppInventor. With the help of extensions there are endless possibilities for apps, but first we need to start with something simple to get started.

We will be using a platform called Niotron IDE. What sets it apart from other extension builders is that this does not require complex Java installations and configuration. This makes it beginner-friendly and easy to understand. You are advised to work on a PC.

🏷️ Tags: #tutorials-and-guides, #extensions 

Step 1. Setting up your project

4. A screen will be opened for you to enter the properties of your extension. Enter the fields as follows.

Explanations

6. Continue and you will see a chunk of code on your screen. We use Java to create extensions, and we will be working with Java.

7. Delete all of the code and replace it with this.

package com.aicode.operations; 


import com.google.appinventor.components.annotations.*;

import com.google.appinventor.components.common.ComponentCategory;

import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;

import com.google.appinventor.components.runtime.ComponentContainer;


@DesignerComponent(

        version = 1,

        description = "A simple extension to operate addition and subtraction.",

        category = ComponentCategory.EXTENSION,

        nonVisible = true,

        iconName = "")

@SimpleObject(external = true)


public class Operations extends AndroidNonvisibleComponent {


    public Operations(ComponentContainer container){

        super(container.$form());

    }


    @SimpleFunction(description = "Adds up two numbers.")

    public double Add(double number1, double number2){

        return number1 + number2;

    }

    @SimpleFunction(description = "Subtracts number2 from number1.")

    public double Subtract(double number1, double number2){

        return number1 - number2;

    }

}

8. Compile your extension to obtain the AIX file.

Step 2. Compiling Your Extension

2. Congratulations! You have created your very first extension! Click on here to see how to import an extension into App Inventor, and here to see some useful resources.

© Gordon Lu             📧 E-mail     💬 Message