The function selectInput() not supported in Android mode?

This sketch works in Java mode, but when I try to run it in Android mode, I get this error:

The function "selectInput(String,String)" does not exist

According to the “Reference” page on the Processing for Android web site, " Almost all of the Processing API can be used in the Android mode." The reference page really isn’t a reference page, it’s just a small collection of examples. Is there a real reference page for Android mode, or at least a list of what can (or cannot) be used in Android mode?

Here’s the sketch (the error message is on line 2):

void setup() {
  selectInput("Select a file to process:", "fileSelected");
}

void fileSelected(File selection) {
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    println("User selected " + selection.getAbsolutePath());
    fileOpen(selection.getAbsolutePath());
  }
}

void fileOpen(String selection) {
  String[] lines = loadStrings(selection);
  println("there are " + lines.length + " lines");
  for (int i = 0 ; i < lines.length; i++) {
    println(lines[i]);
  }
}

Hi David,

Here is the reason why it is currently not implemented by android mode.

Here the possible solution…

I think, regarding the reference page, that they are only listed the additional functions for Android on that page and for the general functions refer to the java reference.

Cheers
— mnse

I was referring to Processing functions like selectInput(), not Java methods. I’m not sure what JFileChooser() has to do with it. Of course, for Java methods, I’d look at the Java reference page.

I’ll try your suggestion (the SelectFile library), though. It looks like it’s meant to replace the built-in Processing functions selectInput(), selectOutput and selectFolder. But I’d still like to know if there are other built-in Processing functions that don’t work in Android mode, just for future reference.

Hi @David,

Processing java mode is based on java, it uses the underlying methods from java jdk, in case of selectInput the swing module JFileChooser, which is not available for Android, so I pointed out the explanation why selectInput isn’t supported on android mode (follow comment from the link).



I would expect that all OS dependant GUI functionality (like file selection dialog) wouldn’t work on android mode and all OS independent should work, but also can’t tell you in detail which do and which don’t.
Imo, It’s not atypical in software development that sometimes you have to figure that out yourself, and heading for a solution. :wink:

btw. Here are good sources for research:

especially in your case those two chapters:

Cheers
— mnse

1 Like

From the Processing for Android web page: " Almost all of the Processing API can be used in the Android mode."

Hi @David,

Yes! This means not all, but…

:slight_smile:

Cheers
— mnse

1 Like

So would it be that difficult for the developers to list the few that don’t work in Android mode? After all, it is the “reference” page.

Hi @David,

Feel free to issue that the documentation is not sufficient and ask for enhancements of the documentation regarding your needs…

Cheers
— mnse

Done. See [Request] Documentation needs improvement · Issue #719 · processing/processing-android · GitHub

Thanks.

1 Like