Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all 941 articles
Browse latest View live

Android, can't load multiple PImages from folder

$
0
0

Hey, I want to load multiple images from a subfolder into a PImage array. In JavaMode it works without problems.

But when using Android Mode and uploading it to the phone I get a NullPointerException in line 17. So filenames probably won't be created. Why? I have no idea what to further try..

String[] filenames;
PImage[] img;

void setup() {
  String imagepath = dataPath("images") + "/";
  File folder = new File(imagepath);

  // filter (returns true if file's extension is .jpg)
  java.io.FilenameFilter pngFilter = new java.io.FilenameFilter() {
    public boolean accept(File dir, String name) {
      return name.toLowerCase().endsWith(".png");
    }
  };
  filenames = folder.list(pngFilter);

  // define array size
  img = new PImage[filenames.length];
  for (int i = 0; i < filenames.length; i++) {
    println(imagepath + filenames[i]);
    img[i] = loadImage(imagepath + filenames[i]);
  }
}

void draw() {
}

BUILD SUCCESSFUL in 19s 28 actionable tasks: 28 executed FATAL EXCEPTION: Animation Thread Process: processing.test.test, PID: 517 java.lang.NullPointerException: Attempt to get length of null array at processing.test.test.test.setup(test.java:37) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PSurfaceNone.callDraw(Unknown Source) at processing.core.PSurfaceNone$AnimationThread.run(Unknown Source)


Android mode / default Font for Unicode CJK

$
0
0

Hi there

When I developed Android apps with Processing, I always used some custom fonts that I left in the "assets" folder. Making a multi-lingual version of my app, I don't want to add some heavy .ttf or .otf files to my package

How do I createFont() from a default Android fonts, with one that will work in Unicode (CJK included) ?

cheers

How do i Select Image file from Android Device (API 24) in Processing Android Mode

$
0
0

Hi, I am very new to this android mode i tried SelectInput from Processing reference and also tried Select Library for android mode Non of them seem to work .

i want to load images from device in my sketch and use the Pixel RGB Values using get(x,y); and perform certain process on image in Android device.

i need Help in selecting Image file from Android Device Gallery :D Cheers

How to select an image from Android device

$
0
0

Hi! I need some help, please! I'm making an Android app where I want the user to select an image from the gallery to load into the app, I've seen the method selectInput() but it's only working in Java mode for me, not in Android. When trying it in Android mode it gives me this error: The method selectInput(String, String) is undefined for the type "nameOfTheSketch" And says that the Compile Failed.

Error with emulator the default example Particles

$
0
0

I try to run with emulator the default example Particles , but I got this error. I try some sketch permissions but not work. The last error message is:"The APK file is missing and the adb server is shutdown." Imgur -https://i.imgur.com/UDyxGM7.png

modifying wallpaper parameters

$
0
0

I think that the possibility to create live wallpapers for android through processing is very fashinating. However once you create the wallpaper you can only set it in the background of your phone through the live wallpaper selector of your mobile, and you can't change any parameter and you can't see the icon in the menu.

Many live wallpapers on the google play store are structured in such a way that you firstly download it as a normal app, secondly, you can see the icon, and by tapping on it you can change the several parameters of the live wallpaper. Finally, usually in this screen there is a button that opens the live wallpaper selector of the mobile, with the preview of the live wallpaper in question yet open(so that you just need to click "apply").

Is there a way to achieve these features through processing?

Thanks.

SDK agreement

$
0
0

I added android mode and installed SDK, but I accidentally closed the agreement window before accepting. I need to find a way of accepting the agreement. It's a new pc and unfamiliar windows 10.

PGraphics clear() method?

$
0
0

Hi, I have problems clearing a PGraphics layer. Using Java mode, it works perfect, no more with Android mode. I've tried clear(), background(0,0), none works... The only way I found is to recreate the layer... Why is that?

My code, trimmed down to this problem, is like:

        PGraphics layer;
        //only debug version works
        boolean debug=true;
        void setup() {
          size(800, 800);
          layer=createGraphics(width, height);
          layer.beginDraw();
          layer.background(0, 0);
          layer.endDraw();
        }
        void draw() {
          background(128);
          layer.beginDraw();
          layer.ellipse(mouseX, mouseY, 50, 50);
          layer.endDraw();
          image(layer, 0, 0);
        }
        void mousePressed() {
          if (debug) {
            layer=createGraphics(width, height);
            layer.beginDraw();
            layer.background(0, 0);
            layer.endDraw();
          } else {
            layer.beginDraw();
            layer.clear();
            layer.endDraw();
          }
        }

Thanks for your answer.


Simply code in Andoid Mode

$
0
0

In this code bellow i tried to load different texts(defferent names) from a list after touching the "Details" button on my device..The problem is that it shows me the name only fore some seconds but i want to stay there invariably..

    import ketai.ui.*;
    import android.view.MotionEvent;

    Button on_button;  // the button
    int clk = 1;  

    KetaiGesture gesture;

    KetaiList klist;

    KetaiList selectionlist;
    ArrayList<String> textlist = new ArrayList<String>();

    void setup() {  
      size(1000,600);
      orientation(LANDSCAPE);
      textSize(28);
      textAlign(CENTER);
      gesture = new KetaiGesture(this);
       on_button = new Button("Details", 820, 420, 100, 50);
      textlist.add("Patient 1");
      textlist.add("Patient 2");
      textlist.add("Patient 3");
      textlist.add("Patient 4");
      textlist.add("Patient 15");
    }



    void mousePressed()
    {
      if (on_button.MouseIsOver()) {
        selectionlist = new KetaiList(this,textlist); 
      }
    }  
     void onKetaiListSelection(KetaiList klist)
    {
      String selection = klist.getSelection();
      if (selection == "Patient 1")
      fill(150);
         text("Kathy Smith",30,40);


       if (selection == "Patient 2")
         fill(150);
         text("John Doe",30,40);


       if (selection == "Patient 3")

         fill(150);

         text("Sue White",30,40);

       // if (selection == "Patient 4")



    }
    void draw() {  
     background(255);
        on_button.Draw();



    }
    // ==========================================================
     class Button {
      String label; // button label
      float x;      // top left corner x position
      float y;      // top left corner y position
      float w;      // width of button
      float h;      // height of button

      // constructor
      Button(String labelB, float xpos, float ypos, float widthB, float heightB) {
        label = labelB;
        x = xpos;
        y = ypos;
        w = widthB;
        h = heightB;
      }

      void Draw() {
        fill(150);
        stroke(141);
        rect(x, y, w, h, 10);
        textAlign(CENTER, CENTER);
        fill(0);
        text(label, x + (w / 2), y + (h / 2));
      }

      boolean MouseIsOver() {
        if (mouseX > x && mouseX < (x + w) && mouseY > y && mouseY < (y + h)) {
          return true;
        }
        return false;
      }
      public boolean surfaceTouchEvent(MotionEvent event) {
      // Call to keep mouseX and mouseY constants updated
      //super.surfaceTouchEvent(event);
      // Forward events
      return gesture.surfaceTouchEvent(event);
    }
    }

Emulator not booted

$
0
0

I get this message when I try to run sketch in emulator:

Emulator process exited with status 1. EmulatorController: Emulator never booted. NOT_RUNNING Error while starting the emulator. (NOT_RUNNING)

Any suggestions?

Not running in connected device

$
0
0

I get this message "Failure [INSTALL_FAILED_OLDER_SDK]" when I try to run on device. Is it just my phone's too old?

FFT to identify bird's singing

$
0
0

Hello, i'm sorry if i'm not posting in the right Category, i'm new to the forum.

I'm working on a project for hiking help for android, and i thought about a functionnality that can be fun, recognizing a bird's singing. The idea is to record a bird that you pass by and the database tells you which species it is.

I'm not a pro of sound processing, but i though that implementing an FFT could help. I was planing on using the FFT to get the max-min amplitude and compare it with the database's pre-processed information, of course i don't plan on using only the min-max indicators.

I inspired my code from this: https://github.com/blanche/shayam/blob/master/java/at.lw.shayam/src/at/lw/shayam/AudioAnalysis.java and as much as i undestand the maths behind the fourrier transform, i don't get everything in that code.

So here are my questions:

  1. The chunks are used to accelerate the computing time of the FFT ? if we have a 2^n chunks, we'll have 2^n smaller FT processed ?

  2. The results[][] 2d Complex Array contains... complexs. But i don't understant what is x and y in results[x][y], how can you find the frequency and the amplitude. (of course i'll have to convert the complexs to doubles)

  3. Do you think this approach is enough ? the projet is not professional so i'm not trying to get a recogntion rate of 100% !

Thank you for your answers.

PGraphics unpredictable and unconsistent behaviour in Android mode

$
0
0

I'm developing an Android live wallpaper and I'm struggling with various problems the PGraphics objects have when rendering. The main problem is the impossibility to clear a PGraphics object with alpha values every frame, and everything I've tried works lika a charm in Java mode.

I'm using P2D as main renderer and the default for the Graphics object one because a whant to obtain a scaled pixel effect using the OpenGL nearest neighbor trick, but that same trick cannot be applied to a PGraphics rendering (so I use default + noSmooth() for this one). After Drawn everything on the PGraphic object, I scale the image on screen using the copy() method.

The result should be an image composed by PImage and PGraphics objects, but these last does not clean after a clear() or background(0,0) call so the image upon them is additive. The clear() call in particular gives me a tiny performances drop, while background(255,255) does its job so it's working fina as method.

I've tried every possible turnaround but nothing has the same performances/appearence as should be in this common way not working because of these problems. I don't know if I'm missing something or if I'm too stupid to figure out a simple solution.

here is a piece of the code that works on Java mode and does not work in Android mode:

pioggia.beginDraw();
pioggia.background(0,0);     //or clear()
for(int i = 0; i<gocceNum; i++){
   gocce[i][2] = (gocce[i][2]+gocceSpX*0.25)%back1.width;
   gocce[i][3] = (gocce[i][3]+gocceSpY*0.25)%back1.height;
   pioggia.set((int)gocce[i][2],(int)gocce[i][3], #355B4A);
}
pioggia.endDraw();
copy(pioggia, (int)quantize(disp*0.4, scalaH), 0, sw, sh, 0, 0, width, height);

"pioggia" is the PGraphics object, gocce is a 2D array of float values. Any help or hint would be super awesome ç_ç

Saving a high score

$
0
0

Hi all! Hope you're having a good day.

I recently made an android game and I want to be able to save a high score. I've tried looking at other discussions on this forum but I couldn't find anything relevant to Android mode. Most of it was to do with Java mode. If it's relevant, I only need to save a single number at any one point in time.

Here are the steps that I believe I need to take in order to create a high score:

  1. Upon opening the app, check if a highscore.txt file is saved and if so, load it. Otherwise, create a new highscore.txt file with its only content being '0'.

  2. Upon 'death', aka playing and losing the game, compare the number in the highscore.txt file against the current score.

  3. Overwrite the highscore.txt file with the higher score.

My score is an int value named currentScore.

I've tried tinkering around to implement it myself, but I don't know where to start with permissions and everything.

Any help would be greatly appreciated! Have a nice day :)

Joystick while Being able to shoot.

$
0
0

Hey, I was creating a game and was wondering if there was a way I could have a joystick in the bottom left of the screen while being able to shoot by pressing anywhere on the right side of the screen. The code I currently have stops the joystick when you shoot and you have to let go of the joystick and then tap it again. Thanks.


Different sizes on different devices

$
0
0

Hi all! I hope you're having a good day.

I recently made and published a small game on the Google Play Store, but I found that it appears different on different devices. I've tried to debug and find out what's causing the problem and I've narrowed it down to different devices having different pixel densities, since I hardcoded values for the sizes of all my objects. I tried dividing these hardcoded values with displayDensity but the objects are still far too large. How can I go about standardising the appearance across devices?

Also, to avoid this inter-device incompatibility in the future, how should I be structuring my code instead?

Thank you all!

Removing mouseover state in controlP5

$
0
0

Having a small problem with controlP5 in android. The first press of a button triggers the mouseoverstate and not a trigger of the button. Is there anyway to bypass this? I have tried to set the mouseOver to true but doesnt help.

The three image files are being used for debug. Really i only need two.

PImage[] imgsMinus = {loadImage("Volume-2.png"), loadImage("Volume-1.png"), loadImage("Volume.png")};
PImage[] imgsPlus = {loadImage("Volume-2.png"), loadImage("Volume-1.png"), loadImage("Volume.png")};

cp5.addButton("down")
      .setValue(-1)
      .setMouseOver(true)
      .setImages(imgsMinus)
      .updateSize()
      .setPosition(100, 100)

cp5.addButton("UP")
      .setValue(1)
      .setMouseOver(true)
      .setImages(imgsPlus)
      .updateSize()
      .setPosition(100, 100)

Button Shapes ControlP5

$
0
0

Hi everyone, I am looking for Rounded Toggle Buttons or Sliders in the shape of following image..

427-512

Can anyone advise me in the right direction?

Kind regards

bluetooth on android mode

$
0
0

hi! i'm looking for a way to use bluetooth serial with processing (android mode). i've tried ketai, but it keeps throwing errors on the example. it's probably not updated yet... thanks in advance, RobotMan2412 EDIT: i'm using processing 3 and i'm not going back to processing 2, just for a library

Ketai-NFC READ -> Not action. Why not?

$
0
0

Hello, Good Day!

Android 6.0 / Processing android version3

not error. but not action.

KakaoTalk_20180407_035608689

Please help me. Thank you.

Thank you.

Viewing all 941 articles
Browse latest View live