# The function selectInput() not supported in Android mode?

**URL:** <https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259>\
**Category:** Processing for Android\
**Created:** [December 22, 2022, 3:41pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259 "2022-12-22T15:41:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [December 22, 2022, 3:41pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/1 "2022-12-22T15:41:49Z")

</div>

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):

```auto
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]);
  }
}

```

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 22, 2022, 4:41pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/2 "2022-12-22T16:41:48Z")

</div>

Hi David,

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

> <https://github.com/processing/processing-android/issues/295#issuecomment-279899289>
>
> Hello
> Here is the code I am testing.
> 
> \`import javax.swing.JFrame;
> import jav…ax.swing.filechooser.FileNameExtensionFilter;
> import javax.swing.JFileChooser;
> PImage img;
> final JFileChooser chooser = new JFileChooser();
> FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG image","jpg");
> void setup () {
> size(600, 600);
> imageMode(CENTER);
> img = loadImage("img000.jpg");
> }
> 
> void draw () {
> background(25);
> image(img, width/2, height/2);
> }
> 
> void keyPressed() {
> chooser.setFileFilter(filter);
> if (key=='l') {
> int returnVal = chooser.showOpenDialog(new JFrame());
> if (returnVal == JFileChooser.APPROVE\_OPTION) {
> System.out.println("You chose to open this file: " +
> chooser.getSelectedFile().getName());
> }
> 
> String path=chooser.getSelectedFile().getAbsolutePath();
> println(path);
> img = loadImage(path);
> }
> }\`
> 
> \---------------------------
> processing console gives me the following error message:
> 
> 
> 1. WARNING in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\MainActivity.java (at line 11)
> import android.support.v4.content.ContextCompat;
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> The import android.support.v4.content.ContextCompat is never used
> \----------
> 2. WARNING in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\MainActivity.java (at line 15)
> import android.Manifest;
> ^^^^^^^^^^^^^^^^
> The import android.Manifest is never used
> \----------
> 3. WARNING in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\MainActivity.java (at line 49)
> int check;
> ^^^^^
> The value of the local variable check is not used
> \----------
> \----------
> 4. ERROR in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 8)
> import javax.swing.JFrame; 
> ^^^^^^^^^^^
> The import javax.swing cannot be resolved
> \----------
> 5. ERROR in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 9)
> import javax.swing.filechooser.FileNameExtensionFilter; 
> ^^^^^^^^^^^
> The import javax.swing cannot be resolved
> \----------
> 6. ERROR in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 10)
> import javax.swing.JFileChooser; 
> ^^^^^^^^^^^
> The import javax.swing cannot be resolved
> \----------
> 7. ERROR in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 27)
> final JFileChooser chooser = new JFileChooser();
> ^^^^^^^^^^^^
> JFileChooser cannot be resolved to a type
> \----------
> 8. ERROR in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 27)
> final JFileChooser chooser = new JFileChooser();
> ^^^^^^^^^^^^
> JFileChooser cannot be resolved to a type
> \----------
> 9. ERROR in C:\\Users\\Jeason\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 28)
> FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG image","jpg");
> ^^^^^^^^^^^^^^^^^^^^^^^
> FileNameExtensionFilter cannot be resolved to a type
> \----------
> 10. ERROR in C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 28)
> FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG image","jpg");
> ^^^^^^^^^^^^^^^^^^^^^^^
> FileNameExtensionFilter cannot be resolved to a type
> \----------
> 11. ERROR in C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 41)
> chooser.setFileFilter(filter);
> ^^^^^^^
> JFileChooser cannot be resolved to a type
> \----------
> 12. ERROR in C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 41)
> chooser.setFileFilter(filter);
> ^^^^^^
> FileNameExtensionFilter cannot be resolved to a type
> \----------
> 13. ERROR in C:\\Users\\\*\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 43)
> int returnVal = chooser.showOpenDialog(new JFrame());
> ^^^^^^^
> JFileChooser cannot be resolved to a type
> \----------
> 14. ERROR in C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 43)
> int returnVal = chooser.showOpenDialog(new JFrame());
> ^^^^^^
> JFrame cannot be resolved to a type
> \----------
> 15. ERROR in C:\\Users\\\*\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 44)
> if (returnVal == JFileChooser.APPROVE\_OPTION) {
> ^^^^^^^^^^^^
> JFileChooser cannot be resolved to a variable
> \----------
> 16. ERROR in C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 46)
> chooser.getSelectedFile().getName());
> ^^^^^^^
> JFileChooser cannot be resolved to a type
> \----------
> 17. ERROR in C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\src\\processing\\test\\imgload\\imgload.java (at line 49)
> String path=chooser.getSelectedFile().getAbsolutePath();
> ^^^^^^^
> JFileChooser cannot be resolved to a type
> \----------
> 17 problems (14 errors, 3 warnings)
> 
> BUILD FAILED
> C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\build.xml:15: The following error occurred while executing this line:
> C:\\Users\\\*\*\*\*\*\\AppData\\Local\\Temp\\android5988581650947227062sketch\\build.xml:28: Compile failed; see the compiler error output for details.

Here the possible solution…

> **[GitHub - pif/android-select-file at dlg - Installation](https://github.com/pif/android-select-file/tree/dlg#installation)**
>
> dlg

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

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [December 22, 2022, 9:10pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/3 "2022-12-22T21:10:29Z")

</div>

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.

> **[selectInput() / Reference](https://processing.org/reference/selectInput_.html)**
>
> Open a platform-specific file chooser dialog to select a file for input. After the selection is made, the selected File will be passed to the 'callback' function. If the dialog is closed or canceled, …

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.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 23, 2022, 7:22am UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/4 "2022-12-23T07:22:59Z")

</div>

Hi @David,

> [@David](#):
>
> I was referring to Processing functions like selectInput(), not Java methods. I’m not sure what JFileChooser() has to do with it.

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](https://github.com/processing/processing-android/issues/296) from the link).

* * *

* * *

> [@David](#):
>
> 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.

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. 😉

btw. Here are good sources for research:

> **[Home](https://github.com/processing/processing-android/wiki/)**
>
> Processing mode and core library to create Android apps with Processing - processing/processing-android

> **[Old Wiki](https://github.com/processing/processing-android/wiki/Old-Wiki)**
>
> Processing mode and core library to create Android apps with Processing - processing/processing-android

especially in your case those two chapters:

> **[Old Wiki](https://github.com/processing/processing-android/wiki/Old-Wiki#api-replacements)**
>
> Processing mode and core library to create Android apps with Processing - processing/processing-android

> **[Old Wiki](https://github.com/processing/processing-android/wiki/Old-Wiki#api-changed-gone-or-forgotten)**
>
> Processing mode and core library to create Android apps with Processing - processing/processing-android

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [December 23, 2022, 12:11pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/5 "2022-12-23T12:11:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 23, 2022, 12:53pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/6 "2022-12-23T12:53:35Z")

</div>

Hi @David,

Yes! This means **not all** , but…

> [@David](#):
>
> _ **Almost all** _ …

🙂

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [December 23, 2022, 12:59pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/7 "2022-12-23T12:59:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 23, 2022, 1:50pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/8 "2022-12-23T13:50:00Z")

</div>

Hi @David,

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

> **[Issues · processing/processing-android](https://github.com/processing/processing-android/issues)**
>
> Processing mode and core library to create Android apps with Processing - Issues · processing/processing-android

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [December 23, 2022, 2:28pm UTC](https://discourse.processing.org/t/the-function-selectinput-not-supported-in-android-mode/40259/9 "2022-12-23T14:28:39Z")

</div>

Done. See [[Request] Documentation needs improvement · Issue #719 · processing/processing-android · GitHub](https://github.com/processing/processing-android/issues/719)

Thanks.
