Android SDK .callFunction

I’m having issues with the .callFunction in Android SDK.

The SDK reference gives it as
int resultCode = someDevice.callFunction(“digitalwrite”, list(“D7”, “1”));

and the ParticleDevice.java file as
public int callFunction(@NonNull String functionName, @Nullable List args)

However the List part is giving me issues, and is not used in any of the examples.
I’m currently just trying to interface with the ledToggle firmware so I have:

                    List<String> ledCommands = new ArrayList<String>();
                    ......
                          ledCommands.add("on");

                   .....mDevice.callFunction("ledToggle", ledCommands.get(0));

The ledCommands.get(0) part is giving me the exception

                  incompatible types required: java.util.ArrayList<java.lang.String> found: java.lang.String

Any thoughts?
I’m new to Android development so I’m guessing this is a simple question.
Thanks

You should pass the ledCommands list directly to callFunction. Remove the .get(0) and it should work :smile:

1 Like