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

Attempt to write to null array error

$
0
0

I am trying to create an app that scrambles a picture. It works great in Java mode but I get the following error in Android mode.

FATAL EXCEPTION: Animation Thread Process: processing.test.pic_sensoring, PID: 7254 java.lang.NullPointerException: Attempt to write to null array at processing.test.pic_sensoring.pic_sensoring.setup(pic_sensoring.java:49) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:761)

My abstracted Code:

PImage img;

void setup(){

  size (200,200);
  img = loadImage("KoalaBear.jpg");
  loadPixels();
  img.loadPixels();

int half1 = img.pixels.length/2;
for(int x = 0 ; x < img.pixels.length/2; x++){
  int a = 0;
  if (a != 199){
  a++;
  }else{
  a = 0;
  }

  int y = x/200 + a/200;

if ((x % 10 < 5) &&( y % 10 < 5)) {
        img.pixels[x]  = color(127);  // White
      }//if block

}//for loop



 img.updatePixels();

}

void draw(){
  image(img3,0,0);
}//draw

Processing-Android mode : AlertDialog, How do you code it? Help.

$
0
0

How do you code it? Help. Please help me.

//Import required classes
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.AlertDialog.Builder.*;
import android.app.AlertDialog.*;
import android.content.DialogInterface;


void setup() {

//    activity=(Activity) this.context;
//    activity.runOnUiThread(Runnable r) ;

//Create the AlertDialog
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
//Set the title
alertDialog.setTitle("Alert");
//Set the message
alertDialog.setMessage("This is an AlertDialog!");
//Add the OK button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int which) {
    //The OK button has been clicked
 }});
//Display the AlertDialog
alertDialog.show();
}

void draw() {
}

Error message : 4. ERROR in C:\Users\Administrator\AppData\Local\Temp\android7595228112886938022sketch\src\processing\test\android_test\android_test.java (at line 43) AlertDialog alertDialog = new AlertDialog.Builder(this).create(); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The constructor AlertDialog.Builder(android_test) is undefined BUILD FAILED C:\Users\ADMINI~1\AppData\Local\Temp\android7595228112886938022sketch\build.xml:15: The following error occurred while executing this line: C:\Users\ADMINI~1\AppData\Local\Temp\android7595228112886938022sketch\build.xml:28: Compile failed; see the compiler error output for details.

Total time: 1 second

error

How do you use multi touch in processing android?

$
0
0

So I just got android studio and imported the processing android library into it. I loaded a random example code I found(put a dot where you touch) and it used mousePressed to check if the mouse is down. However, this only works for single touch, and if I place a second finger on the screen, nothing happens. I was just wondering, how do you incorporate multitouch into android processing?

Note: I don't know how to directly program for android at all.

Run Processing Camera sketch on Android

$
0
0

Hi, again. I've got this working Processing sketch just to test the camera:

/** ||******************************
 ** ||
 ** ||
 ** ||
 ** ||*****************************/

import processing.video.*;

Capture video;
int x, y;

void setup()
{
  size(640, 480);
  //
  x = width;
  y = height;
  //
  video = new Capture(this, Capture.list()[5]);
  video.start();
  //
  background(0);
}
/******************************************************/
void captureEvent(Capture video)
{
  video.read();
}
/******************************************************/
void draw()
{
  //
  video.loadPixels();
  image(video, 0, 0, x, y);
}

What am trying to do is, to load that sketch to an Android Studio app. Loading an sketch comes easy for me, they work. But with this one since to not be the case. I also tried this example: https://github.com/omerjerk/processing-video-android

And the experiment results in failure.

So, what would be the correct way of loading a Processing sketch using capture in Android.

Can Someone please Help!! Cant load sketch to android (onRequestPermissionsResult)

$
0
0

Hey there I'm just getting started with the android mode but it doesn't work for me


This is my code:

void setup(){
  fullScreen();
  fill(255, 0, 0);
  noStroke();
}

void draw(){
  rect(50, 50, 20, 20);
}

This is my error:

1. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/MainActivity.java (at line 49)
    int check;
        ^^^^^
The value of the local variable check is not used
----------
2. ERROR in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/MainActivity.java (at line 58)
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The method onRequestPermissionsResult(int, String[], int[]) of type MainActivity must override a superclass method
----------
----------
3. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 4)
    import processing.data.*;
           ^^^^^^^^^^^^^^^
The import processing.data is never used
----------
4. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 5)
    import processing.event.*;
           ^^^^^^^^^^^^^^^^
The import processing.event is never used
----------
5. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 6)
    import processing.opengl.*;
           ^^^^^^^^^^^^^^^^^
The import processing.opengl is never used
----------
6. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 8)
    import java.util.HashMap;
           ^^^^^^^^^^^^^^^^^
The import java.util.HashMap is never used
----------
7. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 9)
    import java.util.ArrayList;
           ^^^^^^^^^^^^^^^^^^^
The import java.util.ArrayList is never used
----------
8. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 10)
    import java.io.File;
           ^^^^^^^^^^^^
The import java.io.File is never used
----------
9. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 11)
    import java.io.BufferedReader;
           ^^^^^^^^^^^^^^^^^^^^^^
The import java.io.BufferedReader is never used
----------
10. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 12)
    import java.io.PrintWriter;
           ^^^^^^^^^^^^^^^^^^^
The import java.io.PrintWriter is never used
----------
11. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 13)
    import java.io.InputStream;
           ^^^^^^^^^^^^^^^^^^^
The import java.io.InputStream is never used
----------
12. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 14)
    import java.io.OutputStream;
           ^^^^^^^^^^^^^^^^^^^^
The import java.io.OutputStream is never used
----------
13. WARNING in /tmp/android7017125211400538057sketch/src/processing/test/androidtest/androidTest.java (at line 15)
    import java.io.IOException;
           ^^^^^^^^^^^^^^^^^^^
The import java.io.IOException is never used
----------
13 problems (1 error, 12 warnings)

BUILD FAILED
/tmp/android7017125211400538057sketch/build.xml:15: The following error occurred while executing this line:
/tmp/android7017125211400538057sketch/build.xml:28: Compile failed; see the compiler error output for details.

Total time: 1 second

Multi Marker does not exist

$
0
0

Hello, I am trying to create an augmented reality code using my android phone. The biggest problem I am running into is after downloading nyartoolkit every time I look at the code it is telling me that the class MultiMaker does not exist. I have never done augmented reality before and am really confused on what to do from here any help that can be given would be much appreciated.

ControlP5 Icon

$
0
0

hii guys, i am trying to run the icon example of the ControlP5 library in processing Mode, in Java Mode its working fine, but in android mode, its not working , it shows this error:

FATAL EXCEPTION: Animation Thread
Process: processing.test.icon, PID: 15031
java.lang.RuntimeException: Font asset not found fontawesome-webfont.ttf
    at android.graphics.Typeface.createFromAsset(Typeface.java:192)
    at processing.core.PApplet.createFont(Unknown Source)
    at processing.core.PApplet.createFont(Unknown Source)
    at processing.test.icon.icon.setup(icon.java:46)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:833)

anyone an idea?

permanent images in android studio

$
0
0

Hi everybody! I have started using android studio. When i try to run sketches there, if i put a rect in draw() for example it remains forever in that position even if i change it's coordinates. Do you have any idea what i am missing? I have followed steps described in tutorial "Developing with Android Studio". Here is a code example:

public class Sketch2 extends PApplet {

 ball MainBall;//= new ball();

public void settings() {
    size(600, 600,P2D);
    //fullScreen();

}

public void setup() {
    background(150,50,50);
   // MainBall= new ball();
    //MainBall.display();

w10 = width/10; System.out.println("K: "+k); }

int k,w10,rh=10;
public void draw() {

    if(MainBall!=null){
        MainBall.display();
        MainBall.fingerForce();
    }

    fill(30,60,k);
    rect(random(0,width),rh,80,30);

//HERE THERE WLL APPEAR ONE RECT FOR EACH LOOP //sphere(30);

/*    if(mousePressed){ rh+=40;
        rect(random(0,width),random(0,height),random(0,40),random(0,40));
        System.out.println("MPPPPPPPP");
    }*/

    if((k+=10) < 255)
    k+=10;
    else k=0;
}

@Override
public void mouseClicked() {
    super.mouseClicked();
    System.out.println("mouseClicked");
    println("println");
}

class ball {
    private int R;
    PVector coord;
    PVector fingerVector;

    ball(){
        R=30;
        this.coord= new PVector (130, 50);
        fingerVector =new PVector(2,2);

    }
    ball(int R){
        this.R = R;
        this.coord= new PVector (width/2, height/4);
        fingerVector =new PVector(0,0);
    }
    void fingerForce(){
        if(mousePressed){
            fingerVector.add(mouseX-pmouseX,mouseY-pmouseY,0);
            coord.x +=2;
            coord.y+=1;
        }
       // coord.add(fingerVector);
    }

    void display(){
        //pushMatrix();
       // translate(this.coord.x,this.coord.y);
        sphere(this.R);
        //rect(100,20,80,80);

       // popMatrix();

        rect(this.coord.x+20,this.coord.y+20,10,10);
    }



}

}

Additional info: same thing happens when using P3D or using none of them. here something from gradle if matters anything
minSdkVersion 15 targetSdkVersion 23 maxSdkVersion 25


How to work in andoid with controlP5? Make bigger labels and use keyboard?

$
0
0

Hi! I have some trouble working with controlP5 and android. I have some scrollable lists and their "head" or "label" size is small. I have make bigger letters but background size is still small. Also how to show keyboard when a textfield is clicked/touched? And third question is, how to make a part of the field scrollable? Something like a menu or small scrollable window?

Android VR sketch with osc connection

$
0
0

Hi there im newer for Processing, i wish to create a vr sketch for android phone and send osc message to Supercollider for audio effect, i read about the google cardboard for processing and i wish to know if it work also with gear VR samsung? An how can i send osc messages from the sketch to supercollider, maybe it is possible run the sketch into the phone/vr from computer, someone could help me? Thanks in advance

Using Wikitude SDK

$
0
0

Hi! I am trying to work with geolocation based AR, and Wikitude SDK seems to be the best choice for what I want to achieve. But I am not familiar with Android Studio, so I was wondering if there is a way to use the Wikitude SDK with processing. Did anyone try something similar??

and if anyone knows an AR library that supports geolocation feature and can be used in Processing, please leave a comment!!

Thank you

The entity name must immediately follow the '&' in the entity reference.

$
0
0

Sorry, bit of a yarn in-coming. When trying to set up android mode to work it wouldn't find the sdk anywhere i pointed it to, I have Android Studio installed, it steadfastly refuses to see the sdk in there (got the version with the sdk, yes), also got the command line tools, refused to see the sdk there either. So had to tell processing to do the automatic download.

Trying to do the google driver update, win 10(starting to feel like a mistake this one) keeps saying that there's no driver in the folder, anywhere. Processing can see phone(image below) but nothing compiles because of this infuriating error:

Error:

Error from inside the Android Tools, check the console.

Console Output:

BUILD FAILED
C:\Users\Rambo\AppData\Local\Temp\android4013554418221838766sketch\build.xml:9: The entity name must immediately follow the '&' in the entity reference.

Total time: 0 seconds

So i'm entirely lost as to what the hell it's talking about.

It doesn't matter what the code is, it's always this error.

Any and all help gratefully recieved.

Capture

Using Android MediaPlayer to play sound.

$
0
0

Hi all, I'm trying to use the code posted here by yelele_brother to play sound in Android mode. (Code posted below for ease of reference.)

It is currently throwing an error that the getAssets(); method does not exist. I checked the Media Player reference here and can't see a getAssets() method. So since this method is no longer available, my question is: How do I make this code work? I've tried looking for ApWidgets but the google code page is shutdown, Cassette doesn't work for me and there appear to be few other solutions as far as I can find.

    import android.media.*;
    import android.content.res.*;
    void setup()
    {
      size(10,10,P2D);
      try {
        MediaPlayer snd = new MediaPlayer();
        AssetManager assets = this.getAssets();
        AssetFileDescriptor fd = assets.openFd("test.mp3");
        snd.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
        snd.prepare();
        snd.start();
      }
      catch (IllegalArgumentException e) {
        e.printStackTrace();
      }
      catch (IllegalStateException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

WIFI list & Connection by android mode (at Processing Tool)

$
0
0

WIFI list & Connection by android mode (at Processing Tool)

------------------------------ code------------------- import android.net.wifi.*; import android.content.*; import java.util.*;

Context context;

void connect_to_wifi(){

  //create wifi connection
        String networkSSID = "";
        String networkPass = "";

        WifiConfiguration conf = new WifiConfiguration();
        conf.SSID = "\"" + networkSSID + "\"";   // Please note the quotes. String should contain ssid in quotes

         //For WPA network you need to add passphrase like this:

            conf.preSharedKey = "\""+ networkPass +"\"";

        //Then, you need to add it to Android wifi manager settings:
        WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
        wifiManager.addNetwork(conf);

        //And finally, you might need to enable it, so Android conntects to it:
        List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
        for( WifiConfiguration i : list ) {
            if(i.SSID != null && i.SSID.equals("\"" + networkSSID + "\"")) {
                 wifiManager.disconnect();
                 wifiManager.enableNetwork(i.networkId, true);
                 wifiManager.reconnect();

                 break;
            }
         }
}

void setup() {
  size(480,800);
  noStroke();
  fill(255);
  rectMode(CENTER);     // This sets all rectangles to draw from the center point
  connect_to_wifi();
}

void draw() {
  background(0);
  rect(width/2, height/2, 150, 150);
}

Error Message : FATAL EXCEPTION: Animation Thread Please solve the problem. Help.

displaying a local index.html file with webview

$
0
0

hi, i added a file to sketch and the file is located in sketchname/data/index.html, my problem is how do i point to that file using webview.loadUrl("file:///sketch/data/index.html");

it just returns "webpage not available message" so it can't see the file , could this possible be a permissions error? idk

Thanks for any help in advance.


Visualizing FFT values on a 3D object using microphone input from Android Device.

$
0
0

Hello,

I am having trouble with an audio reactive project I am working on. So far I have a 3D environment that is using the Minim library to analyze FFT values drawn from the microphone of my PC to change the size of the objects in the environment. I am trying to get this effect to work on my Android phone with the "Google Cardboard" library (http://android.processing.org/tutorials/cardboard_intro/index.html). I am able to display the environment and look around perfectly in VR, however I am unable to analyze the microphone input from my phone. I understand this is not possible with Minim, and I have spent hours looking for, and trying various alternative solutions. I am relatively new to programming and many explanations I have found are very advanced. Is there a simple way to achieve this?

Thank you so much.

Saving Locations to server to another aplication use it

$
0
0

Hello,

Im trying to create 2 applications, one that saves the locations on android mode(latitude and longitude) in a webserver (or something similar) and then display a map in another application running on computer. Which are the best way to do the communication between the applications?

ps: im not native english speaker, sorry if I did some mistakes in the question

My First Android Simple Program Errors

$
0
0

Hi all sweet friends.. i m new here and want to work with Processing Android Mode, i have install "Processing-3.2.3" and also download "Android Mode" and also import "AndroidCapture for processing" , "Video" Library through contribution manager and SDK automatically through processing.. i have window 8.1.. Now when i write the following code i have a lots of errors check snap and givin detail Capture

The Class "PApplet" does not exist, The Class "PImage" does not exist, The function "size(int, int)" does not exist, The variable "width" does not exist, The variable "height" does not exist, The Class "PImage" does not exist, The type processing.core.PImage cannot be resolved. It is indarictly referenced from required.class files

if i write any type of simple code i have the same errors all time, i m new please dear friends help me...Thanks

cardboard tutorials?

$
0
0

Hi there, I can't find none example about processing and android with cardboard library, the only one I find is on the official page Processing Android to explain how to start, however I have a lot to ask and understand, first of all how deal with void draw, how many things can be recalculated before the graphic degree, and I stating search example but I don't find nothing, Can you suggest some guides/tutorials who talk about the interaction with cardboard? Thanks

Scale app size

$
0
0

Hi, I would like to create a simple game, but I want the layout to be always the same, despite the size of the screen. My game uses a window of 540x960, and I would like to force my phone (which is 2560x1440) to "scale" the app, to be in fullscreen, but keeping the right size of the buttons. Is it possible ?

Viewing all 941 articles
Browse latest View live