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

Cannot access Android mode on latest version of processing?

$
0
0

So I added android mode and then processing (latest version) shut down and gave me this error. I have the Android SDK installed so I have no idea what I did wrong. All I want to do is use Android Mode but nothing is working. error


How can I query an SQLite database from my Android Processing Sketch?

$
0
0

I cannot figure out how to do it using Processing 3. Does anyone know how?

about playing audio file (.wav) backwards (reversing)

$
0
0

i have an app (android) which works with sounds, transforming them (changing pitch or rate and so on) at run time; one of the tranformations consists in playing some sound reversing it. Java Sound class can do that but you cannot use this class in android. So i had to find the way to do that and found a solution which works (as for me!) and perhaps can help others (i have seen on SO that this question is not really answered); yet i have a problem which is exposed in the code below. Is anybody able to explain to me why the "first solution" does not work???

--- CODE (some imports are not used in this method)

    import java.io.BufferedInputStream;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.nio.ByteBuffer;
    import android.media.AudioFormat;
    import android.media.AudioManager;
    import android.media.AudioTrack;
    import android.os.Environment;

    AudioTrack audioTrack;
    FileInputStream is;



    void setup(){
      orientation(PORTRAIT);
      joueenvers();
    }




    public void joueenvers(){

      int minBufferSize = AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, 
                AudioFormat.ENCODING_PCM_16BIT);

    audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, 
             AudioFormat.ENCODING_PCM_16BIT, minBufferSize, AudioTrack.MODE_STREAM); 

    audioTrack.play();

    byte [] buffer = new byte[2048];
    File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/clock.wav");//try putting some wave on your sdcard



    try {
      is = new FileInputStream(file);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

      try {

        buffer = convertStreamToByteArray(is, 2048);// this could be done more quickly importing org.apache.commons.io.IOUtils but my method works also...

      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }




    //try {
    //while((i = inputStream.read(buffer)) != -1)//for reading without inverting uncomment
        audioTrack.write(buffer, 0, buffer.length);
    //} catch (IOException e) {
    // TODO Auto-generated catch block
    //e.printStackTrace();
    //}
    try {

    is.close();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }  

    public static byte[] convertStreamToByteArray(InputStream is, int size) throws IOException {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buff = new byte[size];
        int i = Integer.MAX_VALUE;
        while ((i = is.read(buff, 0, buff.length)) > 0) 
        {
            baos.write(buff, 0, i);
        }

        return reverse(baos.toByteArray());
    };


    public static byte[] reverse(byte[] array) {

        if (array == null) 
        {
            return null;
        }

        byte[] result = new byte[array.length];
        //array.length = 11365644 - that is the exact size from the file choosen

        for(int i = 0 ; i < 44 ; i++)// copy  header for 44 bytes
        {
          result[i] = array[i];


        }



        //copy other bytes inverting the order:: 2 solutions=== HERE IS THE PROBLEM

        // first one which seems logical but does not work!!!! i take the first value from  array[] and put it a the end of result[]:: only noise, not any error message

      /*  int o = array.length-1; 

        for (int l = 44 ; l < array.length ; l++ )//44 is after header

        {
          byte value1 = array[l];//first value will be array[44];

          result[o]= value1;// last value for result will be the first one from the array (array[44])
          o--;
           if(l<50 && l>=44){
            System.out.println("o=======" + o);//returns array.length decrementing it at each loop 
          }

        }*/


        //second one which seems only the contrary but  works!!! i take the last value from the array and put it at the beginning


        int z = array.length;

        for (int l= 44; l < array.length; l++ )

        {

        byte value1 = array[z-l];// 11365600 the first time as asked for: correct, this is the last value from array[]

          if(l<50 && l>=44){
            System.out.println ("z-l=====" + (z-l));
          }

          result[l] = value1;// first value from result[] = last value from array[] 


        }




        return result;
    };

RGB led over Bluetooth issue

$
0
0

Hi, folks!

This is my first post on the forum, so i hope i can find the solution of my issue.

I was using controlp5 and ketai libraries.

My code:

import ketai.net.bluetooth.*;
import ketai.ui.*;
import ketai.net.*;
import ketai.sensors.*;
import controlP5.*;

KetaiBluetooth bt;
KetaiList klist;
KetaiSensor sensor;

ControlP5 cp5;

ArrayList devicesDiscovered = new ArrayList();

byte[] a={'r'};
byte[] b={'g'};
byte[] c={'b'};

byte redValue = 0;
byte greenValue = 0;
byte blueValue = 0;

void setup()
{
  size(displayWidth,displayHeight);
  orientation(LANDSCAPE);
  background(0);

  
  cp5=new ControlP5(this);


    cp5.addSlider("redValue")
       .setPosition(50, 40)
       .setSize(250, 550)
       .setRange(0.0,255.0)
       ;
       
    cp5.addSlider("greenValue")
       .setPosition(500, 40)
       .setSize(250, 550)
       .setRange(0.0,255.0)
       ;
       
    cp5.addSlider("blueValue")
        .setPosition(950, 40)
        .setSize(250, 550)
        .setRange(0.0,255.0)
        ;
        
  cp5.getController("redValue").getValueLabel().align(ControlP5.RIGHT, ControlP5.TOP).setPaddingY(0);
  cp5.getController("redValue").getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM).setPaddingY(0);
  cp5.getController("greenValue").getValueLabel().align(ControlP5.RIGHT, ControlP5.TOP).setPaddingY(0);
  cp5.getController("greenValue").getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM).setPaddingY(0);
  cp5.getController("blueValue").getValueLabel().align(ControlP5.RIGHT, ControlP5.TOP).setPaddingY(0);
  cp5.getController("blueValue").getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM).setPaddingY(0);
     
 bt=new KetaiBluetooth(this);
  
  bt.start();
  
  klist = new KetaiList(this, bt.getDiscoveredDeviceNames());
  
}

void draw()
{
}

void onKetaiListSelection(KetaiList klist1)
{
  String select = klist1.getSelection();
  bt.connectToDeviceByName(select);
  klist = null;
}

void redValue(byte[] rV)
{
  bt.broadcast(a);
  bt.broadcast(rV);
}

void greenValue(byte[] gV)
{
  bt.broadcast(a);
  bt.broadcast(gV);
}

void blueValue(byte[] bV)
{
  bt.broadcast(a);
  bt.broadcast(bV);
}

And my error :

java.lang.IllegalStateException: Fragment rgb_por{41ca2a10} not attached to Activity at android.app.Fragment.startActivityForResult(Fragment.java:1072) at android.app.Fragment.startActivityForResult(Fragment.java:1063) at ketai.net.bluetooth.KetaiBluetooth.(KetaiBluetooth.java:99) at processing.test.rgb_por.rgb_por.setup(rgb_por.java:82) 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:841) FATAL EXCEPTION: Animation Thread Process: processing.test.rgb_por, PID: 28464 java.lang.IllegalStateException: Fragment rgb_por{41ca2a10} not attached to Activity at android.app.Fragment.startActivityForResult(Fragment.java:1072) at android.app.Fragment.startActivityForResult(Fragment.java:1063) at ketai.net.bluetooth.KetaiBluetooth.(KetaiBluetooth.java:99) at processing.test.rgb_por.rgb_por.setup(rgb_por.java:82) 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:841)

PGraphics don't works

$
0
0

I have tried every possible combination and still PGraphics seems not to work in Android Mode. Is this a well known problem?

How can I modify the code of saving score so it can work on Android mode?

$
0
0

The code works on one of my games on Java mode. But on another game that I want to run only in Android mode does not work. The code I created is:

class Score {
  PrintWriter writer;
  String[] reader = loadStrings("scores.txt");
  int data;
  int data2;
  int data3;

  Score() {
    data  = 0;
    data2 = 0;
    data3 = 0;
  }
  Score(int receiver, int receiver2, int receiver3) {
    data  = receiver;
    data2 = receiver2;
    data3 = receiver3;
  }

  void write() {
    int[] collection = {data, data2, data3};
    writer = createWriter("scores.txt");
    for (int i = 0; i < collection.length; i++)
    writer.println(collection[i]);
    writer.flush();
    writer.close();
  }

    int read() {
    int piece = 0;
    piece  = int(reader[0]);
    return piece;
  }
    int read2() {
    int piece2 = 0;
    piece2 = int(reader[1]);
    return piece2;
  }
    int read3() {
    int piece3 = 0;
    piece3 = int(reader[2]);
    return piece3;
  }
}// End Class

How to run Android Mode in Processing 3?

How to make android mode is always active

$
0
0

i make a project using oscP5, in this app i want to change background if any data receive via osc. but the problem is there is time out in android that will go to lock screen if no activity, its make me have to touch the screen before time out.

how to make it always on the screen app?


How to get my address with Geocode

How can I transplant this processing PC terminal to Android devices?

can't build file and download to device

$
0
0

this is what i get when "run for device":

-set-mode-check:

-set-debug-files:

-check-env: Android SDK Tools Revision 23.0.5 Installed at C:\Users\barry\AppData\Local\Android\android-sdk

-setup: [echo] Project Name: sketch_android001 Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup: Using latest Build Tools: 21.1.1 [echo] Resolving Build Target for sketch_android001...

BUILD FAILED C:\Users\barry\AppData\Local\Android\android-sdk\tools\ant\build.xml:542: Unable to resolve project target 'android-19'

Total time: 0 seconds

thanks in advance

Ketai/Processing change/bug?

$
0
0

Any Ketai users?

I have Processing 3.0b6 android mode running (yeah), but am getting a new error for a sketch that has been fine up to now. I am guessing this has something to do with whatever changes have been made in android.core?? but don't really know :)

For the code (very stripped back) below, Processing is telling me that the function "surfaceTouchEvent(event)" does not exist.

Is this a Processing bug or a Ketai issue with 3.0b6? And can I fix somehow? Perhaps I need to do something else/additional at the import stage?

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

KetaiGesture gesture;

void setup() {
}

void draw() {
}

//this callback is copied direct from Rapid Android Development and used to be fine...
public boolean surfaceTouchEvent(MotionEvent event) {
  //call to keep mouseX, mouseY, etc updated
  super.surfaceTouchEvent(event);
  //forward event to class for processing
  return gesture.surfaceTouchEvent(event);
}

Hope someone can help.

Mark

Building for Android from SubLime

$
0
0

Has anyone had success in building to Android using SubLime editor and the latest Android Branch? Just curious if this is possible. Right now, I have to switch over to Processing to build (which is not that bad although it messes up indentations) so I was hoping for a solution where I could build directly from SubLime into the device.

Not sure where to start, I didn't quite understand the Android Branch on how it's thought to work exactly ...

3.0b6 errors

$
0
0

Like a few other users, I am struggling to get working with 3.0b6 AndroidMode. I have everything installed as far as I can tell using the embedded sdk downloader etc., and I can do an export of my sketch which loads fine into AIDE on my phone where I can then create an apk.

But, I used to be able to 'run on device' with Processing up until having to get a new PC this and re-install everything, and now I get some weird errors. The first is when importing an android library class eg:

import android.view.MotionEvent;

which gives the error message:

** Only a type can be imported. android.view.MotionEvent resolves to a package**

And the second is when I run on device where the console says:

**Using latest Build Tools: 23.0.1 [echo] Resolving Build Target for androidTest...

BUILD FAILED C:\Users\Mark\Documents\Processing\modes\AndroidMode\sdk\tools\ant\build.xml:538: Unable to resolve project target 'android-22'**

I know others seem to have similar issues... any solutions though?!

Mark

MANIFEST_MALFORMED

$
0
0

Has anybody else come across this...

Run on device gets through the zip align etc but then I get a message to say the Manifest is Malformed

Any ideas?

-do-debug:
Running zip align on final apk...
     [echo] Debug Package: C:\Users\Mark\AppData\Local\Temp\android818157942760425067sketch\bin\SessionShedDemo1_0-debug.apk
[propertyfile] Creating new property file: C:\Users\Mark\AppData\Local\Temp\android818157942760425067sketch\bin\build.prop
[propertyfile] Updating property file: C:\Users\Mark\AppData\Local\Temp\android818157942760425067sketch\bin\build.prop
[propertyfile] Updating property file: C:\Users\Mark\AppData\Local\Temp\android818157942760425067sketch\bin\build.prop
[propertyfile] Updating property file: C:\Users\Mark\AppData\Local\Temp\android818157942760425067sketch\bin\build.prop

-post-build:

debug:
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]

keytool error when running a script in android mode

$
0
0

Hi, I am running processing 3.0b5 with the latest android version. The PC is running linux mint 17.1.

When trying to run a simple script i get the following error when trying to run in the emulator: BUILD FAILED /home/richard/Dev/processing-3.0b5/android-sdk-linux/tools/ant/build.xml:958: The following error occurred while executing this line: /home/richard/Dev/processing-3.0b5/android-sdk-linux/tools/ant/build.xml:969: The following error occurred while executing this line: /home/richard/Dev/processing-3.0b5/android-sdk-linux/tools/ant/build.xml:312: com.android.sdklib.build.ApkCreationException: Failed to create key: Cannot run program "/opt/processing3/java/bin/keytool": error=2, No such file or directory JAVA_HOME is set to: /opt/processing3/java

I have altered the /etc/environment file to point the PATH and JAVA_HOME to the the Java-7-oracle directory: sudo nano /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-7-oracle" JAVA_HOME=/usr/lib/jvm/java-7-oracle

and this seems to have been accepted: ~ $ echo $JAVA_HOME /usr/lib/jvm/java-7-oracle ~ $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-7-oracle $ which java /usr/bin/java

However i am still getting the error indicating that JAVA_HOME is still set to /opt/processing3/java.

It seems that i am doing something wrong with setting teh environment variables maybe. Does anybody know how to fix this?

Any help is much appreciated.

Cheers.

Need AVD (et al.) tutorial

$
0
0

Daniel Sauter's book Rapid Android Development is excellent but glosses over the potential troubles in moving from straight Processing ( my original interest) to Android emulation mode. My attempts result in the EmulatorController issuing the bad news: "Emulator never booted." I am running Processing 3.0b6 on Windows 10 Lenovo PC.

Rather than document every specific action I've taken, can someone point to or write a brief general check list on steps to ensure consistency between AVD objects, SDK version, system images, etc.? Many thanks.

android SDK could not be loaded.

$
0
0

Getting the first "hello world" app to run is usually very frustrating, and this is no exception. I'm sure many people have had this problem, but i can find a clear explanation of what to do.

I'm trying to follow: http://www.creativeapplications.net/android/mobile-app-development-processing-android-tutorial/

i'm using windows 10, and i just got the newest processing.

I got the "Android SDK Manager" and i checked and installed just about everything on there. When i tried to install android mode in processing I got the message "the android SDK could not be loaded. Use of Android Mode will be all but disabled." I rebooted and open processing again, and the same message pops up while processing is initializing.

maybe it is installing to the wrong folder, or i need to tell processing where to find the SDK.

btw: I got the SDK from here: http://developer.android.com/sdk/index.html and went down to "SDK Tools Only" and d/l-ed installer_r24.3.4-windows.exe

i'm totally stuck please help

how many files can we put in the data folder?

$
0
0

Hello,

I'm trying to export a signed package and I have this problem : when I have 78 files (gif, jpg, mp3) in the data folder (less than 5Mb), the app is created. But when I have more than 78 files, the process doesn't go to its end and no error message is given. It's not due to a file in particular (I tried with different files).

Does anyone have an idea about how fixing this?

Thanks a lot for your help! Jim Rolland

PS : I work on windows 7, processing 2.2.1, Android Studio 1.3.2 and SDK manager API 19.

How do I get the Android View for my sketch?

$
0
0

I want to get access to the Android View object of my sketch. For example to call the setKeepScreenOn function.

How can I do this?

cheers

Phil

Viewing all 941 articles
Browse latest View live