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

Weird behavior with mousePressed on Android Mode

$
0
0

I have the following code in my sketch to detect swiping movement on the screen so I can move the game character accordingly:

if(mousePressed){
  if(mouseXPrevious != -1) {
    xSpeed = mouseX - mouseXPrevious;
  }
  mouseXPrevious = mouseX;
}
else if(mouseXPrevious != -1){
  xSpeed = 0;
  mouseXPrevious = -1;
}

The code works and runs just fine on my Moto X Play (android 6.0.1), but when I tested the game on my old HTC One X (running android 4.2.2) it seemed that only half of the presses go through. When it did go through though, the character kept moving along with my finger as long as I held my finger on the screen. On the next touch, again nothing. On another try: It works again.

I've never ran into this problem on my main phone(the Motorola). What could be causing this?


The import android cannot be resolved

PeasyCam on Android

$
0
0

Hello

This is my first time to post, I am not sure if I put this in the right section of the form.

After 1 day of searching, reading, testing, finally, I got the Android mode up and running. I can successfully run some test sketch, most of them works perfect. However, when I try to run sketches with PeasyCam lib, the console is giving me errors, saying \ant\build.xml XXX has errors. I looked the build.xml file, the error lines read like this.

 <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
            <!-- only convert to dalvik bytecode is *not* a library -->
            <do-only-if-not-library elseText="Library project: do not convert bytecode..." >
                <!-- special case for instrumented builds: need to use no-locals and need
                     to pass in the emma jar. -->
                <if condition="${build.is.instrumented}">
                    <then>
                        <dex-helper nolocals="true">
                            <external-libs>
                                <fileset file="${emma.dir}/emma_device.jar" />
                            </external-libs>
                        </dex-helper>
                    </then>
                    <else>
                        <dex-helper />
                    </else>
                </if>
            </do-only-if-not-library>
        </do-only-if-manifest-hasCode>


  verbose="${verbose}">
                <path path="${out.dex.input.absolute.dir}"/>
                <path refid="out.dex.jar.input.ref" />
                <external-libs />

I am using Processing 3.2.3 Android SDK API 7.1.1 (25)

Here is the code I am running into problems when I try to run it on my Android device (physical device);

import peasy.*;
PeasyCam cam;

void setup () {
  size (800, 800, P3D);
  cam = new PeasyCam(this, 200);
}

void draw () {
  background(80);
  box(90);
}

Could someone possibily please help?

Code viewer for android

$
0
0

Ive found apps that let me type code on my android devices, but cant seem to find one that lets me open and view files ive downloaded from sites like "instructables". Im very new to programming in general, as well as processing, and it would be amazing to be able to study codes during my little breaks throughout the day, when i only have a phone or tablet. I dont yet need to write any lines of code on my phone, i might never need to, but i really want to be able to study the basic examples for a variety of projects (especially projects for arduino) and concepts. Is there a popular app that allows me to open the regular processing files ( no need to be able to build , just read popular samples). ??? The trainer apps dont have this feature.

converting Rfduino library to .jar file to support B​luetooth L​ow E​nergy for P​rocessing An​droid

$
0
0

I read https://github.com/joshuajnoble/blepdroid to convert the rfduino library into .jar file and add it to processing libraries. I am very new to android and I did not understand how to extract the .jar file as mentioned on the link. Could anyone help me figure out how the get the .jar file for the rfduino library?

-Thanks Goutham

PShape.setStroke and PShape.setFill crash sketch on Android

$
0
0

My curlicue fractal clock works 100% fine in Java mode, but as soon as I try to set the stroke or fill colour on Android, the sketch crashes as soon as it runs. I don't know if this is relevant, but I'm on a Moto G with Android 5.1, running sketches via Processing 3.2.1. Full code is below; the lines with setStroke and setFill are currently commented out so that it runs on Android.

Any ideas for a workaround? Should I file this as a bug report on GitHub? Thanks!

 import java.util.Date;
 /** Chronosynclastic Curlicue Cog Clock Clock

 <p>Each curlicue has its period printed on it: the fastest loops right back to the top every five seconds.
 The slowest takes one minute.
 Their shapes tell a mathematical story.</p>

 By Fergus Murray
 */

PShape cogShape;
float x, y, ox, oy, f, flipper=1, rot;
double df=0, ddf=0;
int i=0;
boolean drawDigitalClock=true, drawAnalogueClock=false, drawSecondCurlicues=true, drawDayCurlicue=true;
long startTime;

void setup() {
  //fullScreen();
  //size (displayHeight, displayHeight); // In case you want it in a square.
  size (600, 600); // About right for use in a web page.
  frameRate (24);
  colorMode (HSB, 360); // So we can use hue, saturation and brightness
  background (0, 0, 0);
  Date theDate=new Date();
  startTime=theDate.getTime(); // Our base time for calculating the clock
  cogShape=createShape();
  cogShape.beginShape ();
  float radius=12; // The stroke weight for shapes seems to be stuck at 1 (?) so this mainly controls that, indirectly.
  float cogPoints=12;
  //float cogTeeth=6;
  flipper=-1;
  for (int i=0; i<cogPoints; i++) {
    // Alternate way of making teeth, modulating the radius by a sine wave, produces puzzlingly asymmetrical star/flower-like cogs
    //cogShape.vertex (radius*(1.0+0.8*cos(i*TAU*cogTeeth/cogPoints))*cos(i*TAU/cogPoints), radius*(1.0+0.8*cos(i*TAU*cogTeeth/cogPoints))*sin(i*TAU/cogPoints));
    cogShape.vertex (radius*(1.0+0.2*flipper)*cos(i*TAU/cogPoints), radius*(1.0+0.2*flipper)*sin(i*TAU/cogPoints));
    cogShape.vertex (radius*(1.0-0.2*flipper)*cos(i*TAU/cogPoints), radius*(1.0-0.2*flipper)*sin(i*TAU/cogPoints));
    flipper=-flipper;
  }
  cogShape.rotate(PI/12);
  cogShape.endShape(CLOSE);
  orientation(PORTRAIT);
}
void draw() {
  background(0);

  // First, a digital clock
  if (drawDigitalClock) {
    fill(60, 248, 360);
    textSize(42);
    text(nf(hour(), 2)+" : "+nf(minute(), 2)+" : "+nf(second(), 2), width/2, height-84);
  }
  pushMatrix();
  translate(width/2, height/2);
  // curlicue (period, length, width, baseHue, hueRange, lines, degree)
  if (drawDayCurlicue) {
    curlicue (43200, 180, width/90, 40, 120, true, 2); //   (1 rev/12 hours)
  }
  if (drawAnalogueClock) {
    curlicue (43200, 1, width/5, 40, 0, true, 1); //   (1 rev/12 hours)
    curlicue (3600, 1, width/4, 150, 0, true, 1); // seconds (1 rev/minute)
    curlicue (60, 1, width/4, 180, 0, true, 1); // seconds (1 rev/minute)
  }
  if (drawSecondCurlicues) {
    for (float i=1; i<=12; i++) {
      pushMatrix();
      rotate (i*PI/6);
      translate(0, -width/3);
      rotate (-i*PI/6);
      curlicue (i*5, 4+(int)(i), width/42, i*5, (int)(i*5), false, 2);
      popMatrix();
    }
  }
  //curlicue (31622400, 1080, 2, 40, 0, true, 2); //   (1 rev/366 days)
  popMatrix();
}

void curlicue(double period, int curlLength, float stepSize, float baseHue, int digit, boolean lines, int degree) {
  rot=0;

  ddf=(TWO_PI*(double)(startTime+millis())/(1000*period))%TWO_PI; // The time, as a fraction of the period
  df=ddf;
  if (curlLength==1) f=(float)df;
  else f=0;
  x=0;
  y=0;

  strokeWeight(16);
  //lines=true;
  flipper=0;
  for (i=0; i<curlLength; i+=1) {
    stroke (baseHue+((float)i/curlLength)*digit, 360, 360, 180);
    //stroke (180);
    if (i==11 && degree==1) {
      stroke (360);
    }
    if (flipper==1) {
      if (degree==1) {
        f+=ddf;
      } else if (degree==2) {
        f+=df;
      } else if (degree==3) {
        f+=ddf*ddf;
      }
      df+=ddf;
    }
    ox=x;
    oy=y;
    x+=stepSize*sin(f);
    y-=stepSize*cos(f);
    if (lines) {
      strokeWeight(4.5);
      //stroke(300);
      if (flipper!=2) { // I currently want to draw all the lines, but this is optional.
        line(x, y, ox, oy);
      }
      if (i>0) {
        strokeWeight(stepSize/8);
      } else {
        strokeWeight(24);
      }
    } else {
      strokeWeight(stepSize/2);
    }
    fill(0);
    pushMatrix();
    translate(x, y);
    rot=2*f-rot;
    rotate(rot+flipper*PI/6);
    //rotate((float)((f)*(1+flipper))); // Every other cog-marriage has the right alignment
    // So angle2-angle1 is right when flipper goes + to - (or - to +?)
    // The other half of the time the second cog isn't turning fast enough
    // So the angle needs to increase by [ddf?] every time to compensate

    textSize(14);
    textAlign(CENTER, CENTER);
    //cogShape.setStroke(120);
    if (lines==false) {
      fill (i*40, 360, 360);
      //cogShape.setStroke(color((i*30)%360, 360, 360)); // Uncomment either of these lines and it crashes on Android
      //cogShape.setFill(color(baseHue+((float)i/curlLength)*digit, 360*(0.5+flipper), 360));

      shape(cogShape, 0, 0, stepSize*0.6, stepSize*0.6);

      fill(0);
      textSize(stepSize*0.4);
      if (i<2) text(digit, -2, -1); // Print the period on the first two cogs
    }
    popMatrix();
    flipper=1-flipper;
  }
}

void keyPressed() {
  if (key=='s') save("Chrono-"+hour()+"-"+minute()+"-"+second()+"-"+millis()+".png");
}

Has anyone managed to successfully load and display textured .OBJ models using Android Processing?

$
0
0

I'd appreciate any good tips on how to do this with existing .OBJ model with associated .MTL and image texture files

cannot select API 10

$
0
0

Hi, on Ubuntu MATE 16.04 I've a fresh installation of Processing 3.2.3. I downloaded Android Studio and SDK too. Then in Processing menu Android/SDK manager I installed Android 2.3.3 in order to build application with API 10. Nevertheless, when I select in the menu Android/Select Target SDK I can see only API 5 and API 22 24 25 and 21 (Android 5 and 7). I would expect API 10 too...Am I wrong? Thanks


fullScreen doesn't work properly

$
0
0

Hi everyone, I've installed Android Mode 3.0.2 through the IDE. It doesn't work when I work with images with parallax and alpha channel, but it does if I draw an ellipse. I am trying the sketch in the device.

I noticed I need to put fullScreen between settings, because otherwise it crashes from the begining.

1- As soon as I change the orientation it crashes, no messages, it stops working.

void settings(){
  fullScreen();
}

2- With this, it doesn't even start.

void settings(){
  fullScreen(P2D);
}

It throws the following errors: _KetaiSensor: start()... Ignoring <#text> tag. FATAL EXCEPTION: GLThread 2841 Process: processing.test.aceleforce, PID: 22321 java.lang.ArrayIndexOutOfBoundsException: length=480000; index=480000 at processing.opengl.Texture.convertToRGBA(Unknown Source) at processing.opengl.Texture.set(Unknown Source) at processing.opengl.Texture.set(Unknown Source) at processing.opengl.PGraphicsOpenGL.initCache(Unknown Source) at processing.opengl.PGraphicsOpenGL.getTexture(Unknown Source) at processing.opengl.PGraphicsOpenGL$TexCache.getTexture(Unknown Source) at processing.opengl.PGraphicsOpenGL.flushPolys(Unknown Source) at processing.opengl.PGraphicsOpenGL.flush(Unknown Source) at processing.opengl.PGraphicsOpenGL.endDraw(Unknown Source) at processing.core.PApplet.handleDraw(Unknown Source) at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) _

I put Fullscreen in the manifest file. I appreciate any ideas, thanks!.

PD:Which is the faster way to render images with parallax?

could not create a virtual device for the emulator

$
0
0

Hi, problem shown in the question, after hitting "Run in emulator" (note, it's the first time I try to run the emulator, not sure I'm doing the proper things):

Info: -SDK was installed with AndroidStudio, and Processing points to that location. - running on Ubuntu Mate 16.04 - Processing 3.2.3 - Api Target 15

some info from console:

-check-env: Android SDK Tools Revision 25.2.5 Installed at /home/valerio/Android/Sdk

and then:

debug: /home/valerio/Android/Sdk/tools/android create avd -n Processing-0255 -t android-15 -c 64M -s WVGA800 --abi armeabi-v7a, status: 1 611ms stdout: Valid ABIs: default/armeabi-v7a, default/x86, google_apis/armeabi-v7a, google_apis/x86 stderr: Error: Invalid --abi armeabi-v7a, for the selected target.

Second attempt: in Menu/Android/Android AVD Manager I selected and started the (only) device I created in AndroidStudio: Nexus_9_API_22. The Android emulator correctly starts. Then I hit again "Run in Emulator" but I obtain again the same errors.

Thanks!

Android processing

$
0
0

please can anyone send me a link which can help me in learning processing android coding for beginners ? the other one is not clear for me !

Open a camera preview inside a custom Layout (Android)

$
0
0

Hi all, I'm creating a real time app when the user can freely draw on camera preview. But... i don't know how to open a camera preview in my app (for example inside a rect).

Please,help

Sketch doesn't work

OpenGL error 1280 at bot beginDraw(): invalid enum

$
0
0

Hello community.

I am a beginner of Processing and Android Mode. If I am doing something stupid, please bear with me.

I am trying to run a sketch on my android phone, however, Processing console told me "sketch launched on the device,,,,,OpenGL error 1280 at bot beginDraw(): invalid enum"

I then looked at the android device (the device is on Android 6.0), sketch is not runing. Everytime I tapped the sketch icon on the android device, Processing console keeps telling me "OpenGL error 1280 at bot beginDraw(): invalid enum"

Anyone had this problem?

P.S: I can run other other sketch on the same android device without problem. Processing v3.2.3 Android SDK API 7.1.1 (25);

Thank you for your help in advance.

here is the code which I am trying to run.

    import controlP5.*;
    float scale_factor = 1, depth;
    Photo2Mesh pm;
    int resolution;
    ControlP5 cp5;
    void setup() {
      size(600, 600, P3D);
      cp5 = new ControlP5(this);
      cp5.addSlider("depth").setPosition(20, 20).setRange(1, 50).setLabel("Depth");
      cp5.addSlider("resolution").setPosition(20, 80).setRange(2, 15).setLabel("Resolution").setValue(15);
      pm = new Photo2Mesh();
    }

    void draw() {
      background(0);

      hint(ENABLE_DEPTH_TEST);
      pushMatrix();
      translate(width/2, height/2);
      rotateX(radians(mouseX));
      rotateY(radians(mouseY));
      scale(scale_factor, scale_factor, scale_factor);
      pm.render_mesh(depth, resolution);
      popMatrix();
      hint(DISABLE_DEPTH_TEST);
      camera();
    }

Here is the class

    class Photo2Mesh {
      PImage img;
      int cols, rows, resolution, x_pos, y_pos, loc;
      float z, z_pos;
      color c;

      Photo2Mesh() {
        img = loadImage("https://processing.org/img/processing-handbook-second-edition.jpg");
        img.loadPixels();
      }

      void render_mesh(float z, int resolution) {
        this.z = z;
        this.resolution = resolution; // box size
        cols = img.width/resolution;
        rows = img.height/resolution;

        for (int x = 0; x < cols; x++) {
          for (int y = 0; y < rows; y++) {
            x_pos = x * resolution + resolution/2;
            y_pos = y * resolution + resolution/2;
            loc = x_pos + y_pos*img.width;
            c = img.pixels[loc];
            z_pos = map(brightness(img.pixels[loc]), 0, 255, 0, z);

            pushMatrix();
            translate(-width/2, -height/2);
            translate(x_pos, y_pos, z_pos);
            fill(c);
            noStroke();
            box(resolution, resolution, 160);
            popMatrix();
          }
        }
      }
    }

Using Bluetooth BLE for downloading orientation data

$
0
0

Are there libraries and/or examples for using Bluetooth BLE within the Processing Android mode? I did find a library in GitHub: "Bluetooth Low Energy for Processing Android" I couldn't see it in the Processing library list and before learning how to import and use it wondered if anyone else has tried it.

Thanks Peter


A program to mask an image - Android.

$
0
0

Hello, This is my first program to write a code to mask an image and show portion of background image only on mousepress event. The Java code works just fine on desktop(In Java mode). Whereas in Andriod mode, I don't know what I am missing or where the mistake is, but the background image is displayed and the pg object paints itself over and over - how do I correct this? Although mousepress events work just fine. Thanks!!

 PGraphics pg;
    PImage bgimage;
    void setup()
 {
      size(640, 480);
      bgimage = loadImage("background.jpg");
      bgimage.resize(640,480);

      pg = createGraphics(640, 480);
      pg.beginDraw();
      pg.background(0);
      pg.smooth();
      pg.noStroke();
      pg.fill(255);
      pg.endDraw();
    }
    void draw()
    {
      image(bgimage,640,480);

      pg.beginDraw();
      if (mousePressed)
      pg.ellipse(mouseX, mouseY, 100, 100);
      pg.endDraw();

      bgimage.mask(pg);
      image(bgimage,0,0);
    }

integrate processing in existing art app cinegrafix (android)

$
0
0

Hello, I allready have developed an app for art content "cinegrafix" (google store) and i relly want to integrate processing as a tool for artist that can provide their artwork on the platform. can you help me to integrate that tool?

Do you know how difficult it is to do that? I´m looking forward to hear from you, all the best from berlin, thomas

Masking images - Processing for Android.

$
0
0

Hello, This is my first program to write a code to mask an image and show portion of background image only on mousepress event. The Java code works just fine on desktop(In Java mode). Whereas in Andriod mode, I don't know what I am missing or where the mistake is, but the background image is displayed and the pg objects paints itself over and over - how do I correct this? Although mousepress events work just fine. Thanks!!

PGraphics pg;
PImage bgimage;
void setup() {
  size(640, 480);
  bgimage = loadImage("background.jpg");
  bgimage.resize(640,480);

  pg = createGraphics(640, 480);
  pg.beginDraw();
  pg.background(0);
  pg.smooth();
  pg.noStroke();
  pg.fill(255);
  pg.endDraw();
}
void draw()
{
  image(bgimage,640,480);

  pg.beginDraw();
  if (mousePressed)
  pg.ellipse(mouseX, mouseY, 100, 100);
  pg.endDraw();

  bgimage.mask(pg);
  image(bgimage,0,0);
}

database

$
0
0

if i am going to create an app that's helps to sell and buy goods , where database will be stored and how?

How to create an App Lock app for Android ?

$
0
0

Hi ! I wants to create a custom app lock for my phone but idk how can I do ... Can you help me? Thanks you in advance !

Viewing all 941 articles
Browse latest View live