Android build fail(windows)(selectInput() and selectOutput() on android)


#1

I was trying to build something for a android phone, but i got an error that said there’s an error with

selectInput(blah,blah);

and

selectOutput(blah,blah);

so, i want to ask if someone knows how to ask for files on android??

ps. blah,blah means that i don’t want to fill in stuff


#2

@Bunnygamers===

With android that kind of thing can be done with an alertDialog: you create it, give it some title, populate it with a charSequenceArray (got from listFiles() depending where are supposed to be your files), add this array with the alertdialog setItems() method then add to the items some OnClickListener().

Dont forget to add WriteExternalStorage Permission and use a runnable to add your Dialog to P5.


#3

Okay, can you make a thing because i don’t know how to apply that, i will probably understand code better.
But still thanks.






(i am noob)

#4

@Bunnygamers===
Sorry, i dont think it is good to answer as you ask for; i can help seeing what you try…
So:

  • begin to add some simple AlertDialog to your app
    details here: https://developer.android.com/guide/topics/ui/dialogs#java
  • secondly try to get a list of your files (let us say in the DCIM directory); for that use java listFiles()
  • after you have this array[] or this ArrayList() look at the setItems method from the alertDialog
  • try to populate your AlertDialog with the items from the array or arrayList
  • then add onClickListener to the items (required because alertDialog items implements that)
  • finally put your code as a method inside a runnable and call this method when you want (on mouseReleased eg)

dont forget permission (on runtime)


#5

as i said, i don’t know how to apply just text, but i do understand code a little bit more.














i am noob


#6

Can you give an example, please?


#7

@Bunnygamers===
what have you tried till now: put your code.


#8

my code right now is very bad and this:

byte[] i = null;
byte[] a = null;
byte[] o;
String OLoc = null;

void setup() {
  background(0, 0, 0);
  size(106, 37);
  surface.setResizable(true);
}
void imgSelected(File selection) {
  if (selection==null) {
  } else {
    i = loadBytes(selection.getAbsolutePath());
  }
}
void archSelected(File selection) {
  if (selection==null) {
  } else {
    a = loadBytes(selection.getAbsolutePath());
  }
}
void outSelected(File selection) {
  if (selection==null) {
  } else {
    OLoc = selection.getAbsolutePath();
    if (i != null && a != null && OLoc != null) {
      o = concat(i, a);
      saveBytes(OLoc, o);
    }
  }
}

void draw() {
  background(255, 255, 255);
  fill(255, 255, 255);
  fill(255, 255, 255);
  if(i != null){fill(0,255,0);}
  rect(0, 0, width, height/3);
  fill(255, 255, 255);
  if(a != null){fill(0,255,0);}
  rect(0, height/3, width, height/3);
  fill(255, 255, 255);
  rect(0, (height/3)*2, width, height/3);

  fill(0, 0, 0);
  text("SELECT IMAGE", width/2-40, height/6+6);
  text("SELECT ARCHIVE", width/2-49, (height/6)*3+6);
  text("SAVE", width/2-10, (height/6)*5+6);
}
void mousePressed() {
  if (mouseY >= 0 && mouseY <= height/3-1) {
    selectInput("Select Image", "imgSelected");
  }
  if (mouseY >= height/3+1 && mouseY <= (height/3)*2-1) {
    selectInput("Select Archive", "archSelected");
  }
  if (mouseY >= (height/3)*2+1 && mouseY <= height-1) {
    selectOutput("Save", "outSelected");
  }
}

#9

@Bunnygamers === this code has not any chance to work with android; so, i have already told you begin to create an AlertDialog , see the link i have put.


#10

Thanks for the help.


#11

But i still don’t understand.


#12

@Bunnygamers === selectInput() does not work with android: instead you have to use an alertDialog as i have described and it has absolutely no sense that i put code for that if you try nothing.