Hello people
I m trying to make a function which will take 5 integers, do something with them and then return a list of the result 5 integers.
something like that:
public class Extensionic extends AndroidNonvisibleComponent implements Component { @SimpleFunction(description = “create points”)
public static ArrayList WeirdFunction(int a, int b, int c, int d, int e) {
ArrayList points = new ArrayList();
// do something with the numbers here and come up with 5 other integers h, i, j, k, l
points.add(h);
points.add(i);
points.add(j);
points.add(k);
points.add(l);
return points;
}
}
and it gives me this error:
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.IllegalArgumentException: Cannot convert Java type ‘java.util.ArrayList<java.lang.Integer>’ to Yail type
The declarations should be ok because when i comment out this function and i use a function like: @SimpleFunction(description = “Simple addition of 5 numbers”)
public int Addition(int a, int b, int c, int d, int e) {
return a + b + c + d + e;
}
ok,
so if i dont become very pushy, what else should i change in order to make it work ?
public class Extensionic extends AndroidNonvisibleComponent implements Component {
@SimpleFunction(description = “create points”)
public static ArrayList WeirdFunction(int a, int b, int c, int d, int e) {
ArrayList points = new ArrayList();
// do something with the numbers here and come up with 5 other integers h, i, j, k, l
points.add(h);
points.add(i);
points.add(j);
points.add(k);
points.add(l);
return YailList.makeList(points);
}
}
I dont think that by just adding “return YailList.makeList(points);” i will make it work.
Creating a YailList
This code demonstrates how you can return a list which is compatible with all the functions in the list category from the App Inventor website.
import com.google.appinventor.components.runtime.util.YailList;
import java.util.ArrayList;
import java.util.List;
...
List listItems = new ArrayList();
listItems.add(data);
return YailList.makeList(listItems);
so i should make it something
public class Extensionic extends AndroidNonvisibleComponent implements Component {
@SimpleFunction(description = “create points”)
public static ArrayList WeirdFunction(int a, int b, int c, int d, int e) {
List points = new ArrayList();
// do something with the numbers here and come up with 5 other integers h, i, j, k, l
points.add(h);
points.add(i);
points.add(j);
points.add(k);
points.add(l);
return YailList.makeList(points);
}
}
Actually there are different ways to do it. This is how progamming languages works . You can convert List, ArrayList and Object[] to the YailList. YailList supports converting from these types.
Try building your extension with current changes and see what will happen
you re right
i m not new in programming but i m new in Java + Kodular
I didnt plan to make an extension at all
But the app went too far and i thought about making a couple of extensions to get rid of a lot of blocks
I understand you, but there are a lot of extensions are built already, so before creating a new one you should maybe look at the current extensions to find something useful for you.
Taifun has a large collection of extensions for App Inventor in all time. I recommend you to look at the collection
If you just basically want to reduce blocks for a math formula etc you can use procedures to reduce blocks more. I shared some useful block usage in the past, I hope you could decrease your blocks more:
Solution found with the help of
com.google.appinventor.components.runtime.GoogleMap.java Source code
after another 200 pages i read
lol
The Truth Is Out There