Looking for How to create extensions blocks

Dear all Extension developers, can you please tell me how to add block in java code (sorry for my bad English ) look i am new to this any extension developer can provide there whats app number so that the form will not be flood with my questions

Thank you so much for the support friends. Keep up the good work @yusufcihan, @Abhijith_Dominic, @hammerhai, @Ken


If you write a function, then it will be a purple block (method).


@SimpleFunction(description = "Block description")
     public void BlockName(parameters) {
     /* Your code here. */


@SimpleFunction(description = "Join two text.")
     public String Join(String t1, String t2) {
     return t1 + t2;

And this is for the property, green block.


@SimpleProperty(category = PropertyCategory.BEHAVIOR,
      description = "Block description.")
  public String Source() {
    return fileName;


@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_STRING,
      defaultValue = "")
  public void Source(String fileName) {
    this.fileName = fileName;

This is only example, you need to do research to learn more about AI2 Extensions.


Great Work! If someone explained like this to me when i started i could’ve made a lot more extensions and gain experience. Great Work!!


For Yellow ie. Events

public void GotFile(String path){
EventDispatcher.dispatchEvent(this, “GotFile”, path);


To create the Purple (function) block use:

@SimpleFunction(description = "") // Notice @SimpleFunction
public boolean Statement() { 
** boolean can switch to int, String, void, or boolean. Statement can be named
** to the name of your function, do NOT create duplicates. Public can also
** switch to private or public

Example function for boolean:

@SimpleFunction(description = "")
public boolean HasThoughtsAboutMe() {
 return false;

Example function for int:

@SimpleFunction(description = "")
public int HasThoughtsAboutMe() {
 return -1;

Example function for String:

@SimpleFunction(description = "")
public String HasThoughtsAboutMe() {
 return "Nope, we don't care about you.";

Example function for void:

@SimpleFunction(description = "")
public void HasThoughtsAboutMe() {

To create the Amber (event) block use:

@SimpleEvent(description = "") // Notice @SimpleEvent
public void Statement() { 
** This stays a void! Statement can be named
** to the name of your function, do NOT create duplicates. Public can
** also switch to private or public.
** The variables "statement, count", and "crashed" must be thrown when
** this block, so in your block which would throw to this one, you'd use
** Statement("Who knows why your phone died?", 8000, true); Below is
** required to register the block.

Example event with one variable:

@SimpleEvent(description = "")
public void GotAppleCount(int count) {
EventDispatcher.dispatchEvent(this, "GotAppleCount", count);

Example event with multiple variables:

@SimpleEvent(description = "")
public void GotAppleCount(int count, String statement, boolean areApples) {
EventDispatcher.dispatchEvent(this, "GotAppleCount", count, statement, areApples);

Example event with no variable:

@SimpleEvent(description = "")
public void GotAppleCount() {
EventDispatcher.dispatchEvent(this, "GotAppleCount");

Follow @yusufcihan’s example for properties, I no longer use them.


These are excellent examples @yusufcihan, @Abhijith_Dominic & @hammerhai!

@clashwithasif, the above examples are excellent. If you are looking to do something that isn’t listed above, what I do is, look at the .java file for a Component that implements something similar to what I need.
You can find the AI Component Sources here:


Thanks Everyone for these examples
Currently i am newbie that will help me at lot


How to add a visible block to the screen would be nice to know. I’ve gotten pretty far in getting an understanding but im stuck on this 1 line of code which keeps blocking me every time. If y’all have any advice please let me know.



If I am not wrong then extensions are non visible components.


Thats what im thinking after I did some research

1 Like

Thanks for the help ill definitely try it out. And 1 other question. making a purple block to receive color?? I know all the variables and used a few different ways but for some reason I cant figure it out. Basically when the user changing background theme. need guidance and advice dont give me the code.

That’s correct, you can’t add any visual items to the Viewer:

1 Like

Knew it lol

1 Like

Yes, but they are able to animate components (see Phase extension)or add effects (ButtonRipple extension). These are visuble stuff.


To simplify it;

Extensions are non-visible components. However, these non-visible extensions can create visible layouts, modify current components or maybe calculate something. So it doesn’t need to add visible stuff always.


As addition: Extensions are like components, but they do not have any visible parts (UI) by default.

…on the phone mock/preview in the Creator.

Which extension runs instantly (after opening app)?

IDK… :man_shrugging: