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

Get local IP-address of device

$
0
0

Hello,

in my application I would like to display the local IP-address of my device. I found the following on github. It kind of works. However, if I print the result to the console, it isn't a human readable IP-address but a string like fe80::8c3a:e3ff:fe99:345e%p2p0

public String getLocalIpAddress() {
  try {
    for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
      NetworkInterface intf = en.nextElement();
      for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
        InetAddress inetAddress = enumIpAddr.nextElement();
        if (!inetAddress.isLoopbackAddress()) {
          return inetAddress.getHostAddress().toString();
        }
      }
    }
  }
  catch (SocketException ex) {
    // Log.e(LOG_TAG, ex.toString());
  }
  return null;
}

Has anyone got an idea how this could be transformed in a human readable IP-address? I've already looked up the documentation for getHostAddress() which says it should be an IP-address in the form of 127.0.0.1 and the like. But this doesn't seem to be the case...

THanks!


ANdroid+Json, how i can access json api's in android mode?

$
0
0

i have 1 error in this line when i try to build for android mode

json = loadJSONObject("http://api.openweathermap.org/data/2.5/weather?q=London&appid=2de143494c0b295cca9337e1e96b00e0");

Errors

The method loadJSONObject(String) is undefined for the type filename1

Error from inside the android tools

i check internet in the tab sketch permissions but i cant build ...is there a solution for loadJSONObject in android mode or another method to access json api's?

i saw this forum with another example[https://forum.processing.org/two/discussion/2294/processing-android-json-file](https://forum.processing.org/two/discussion/2294/processing-android-json-file) but it doesn't work for me ,it builds but doesn't work on my device ,and i have internet permission for this example

String url = "http://api.openweathermap.org/data/2.5/weather?q=London&appid=2de143494c0b295cca9337e1e96b00e0" ;
 int instanceID;
void setup() {
  size(200, 400);
  background(0);
  String[] homePage = loadStrings(url);
  String jsonFragment = homePage[0];
  JSONObject json = JSONObject.parse(jsonFragment);
  instanceID = json.getInt("id");
  println(instanceID);
}
void draw() {
  text(instanceID,23,23);
}

give me suggestions ,please, i have android device 4.4.2

KetaiSensor & OscP5: sending OSC messages directly from within an event handler

$
0
0

Hello,

I'm trying to implement a sensor based OSC controller. So far I've set up a handler for accelerometer events and I can see from the console output that accelerometer data is being captured properly in an onAccelerometerEvent handler. However, I haven't been able to send OSC directly from within the handler. I've seen e.g. in this example that, even though all necessary data is available within the handler, actual sending is done in the draw function. I've been able to do it like that in my own sketch as well but preferably I'd like to do it in the handler and not be dependant on the framerate at which the draw function executes. Why is it not possible to send OSC from within a sensor event handler? (or, if it is possible, what am I doing wrong?)

example code (I've moved over to AndroidStudio, so the below is translated back to processing - hope my code makes sense...)

import ketai.sensors.*;
import oscP5.*;

OscP5 oscP5;
NetAddress broadcastLoc;
OscMessage oscAcc;
KetaiSensor sensor;

void setup() {
    oscP5 = new OscP5(this, 32000);
    broadcastLoc = new NetAddress("192.168.1.5", 57120);
    sensor = new KetaiSensor(this);
}

void draw() {

}

void onAccelerometerEvent(float x, float y, float z, long time, int accuracy) {
    println("x: " + x + "\ny: " + y + "\nz: " + z + "\naccuracy: " + accuracy);
    oscAcc = new OscMessage("/acc");
    oscAcc.add(x);
    oscAcc.add(y);
    oscAcc.add(z);
    println("broadcastLoc: " + broadcastLoc + "\nOSC msg: " + oscAcc + "\noscP5: " + oscP5);
    try {
        oscP5.send(oscAcc, broadcastLoc);
    } catch(Exception e) {
        // prints just "sending failed: null"
        println("sending failed: " + e.getMessage());
    }
}

Image z-index

$
0
0

Hello i have 2d array filled with different colours. (Just like platformer game map) And i want to make buttons to move the player. Buttons are images (png) and they are drawn at main. The problem is that 2d array is over the buttons and they are not displayed.. Can you help me? thanks

How to setup Processing for Android to receive and send Serial communication over bluetooth ?

$
0
0

How to setup Processing for Android to receive and send Serial communication over bluetooth ? I want to have a serial communication between Arduino and Processing sketch running on my Nexus phone. Processing IDE ver 3.0.b6 Android SDK API: 5.1.1 .

How to use Bluetooth Serial in processing Android mode

$
0
0

I want to have an app that would receive serial data and based based on that data it would do something in a an app .. The data is intended to come from Arduino over HC-06(Serial bluetooth module). I'm not able to find an easy to use suitable way of doing it. Is there any library I should be looking for, if Ketai could be used(PLs show be a barebone example without all the glitters).. Processing Ver: 3.0.b6 or above. Obviously I'm not an Android Junkie, so please guide me how to do it.. I know this far that I need the mac address from the bluetooth module. (I can find and hardcode that one)..

Many thanks for help..

Well be well appreciated..

Latest ADK module for processing 3.0.xx and above

$
0
0

Is there an updated ver of Latest ADK module for processing 3.0.xx and above? If not How can I use the old one ..

I want to talk to Arduino over cable.. That's the intent

Step by step guidance is much appreciated ..

Thanks

BUILD FAILED error 730

$
0
0

hey there,

I'm currently trying to run a processing sketch on my android tablet.

  • I installed the latest java version, the android SDK and processing 2.2.1. (running on Windows 7)
  • Via the Android SDK Manager I installed the latest android SDK Tools as well as API 22, API 19 and API 10. In Extras I also downloaded and installed the Google USB Driver
  • My android SDK path points to the same location as my Android SDK Manager.
  • I set up my Environment variables as explained in http://forum.processing.org/one/topic/android-problems.html here is my "path": C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Common Files\Lenovo;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;C:\ProgramData\Lenovo\ReadyApps;%JAVA_HOME%;%ANT_HOME%;%ANDROID_HOME%;%ADB_HOME%;C:\Program Files (x86)\Java\jdk1.8.0_45\bin;C:\Users\ygruner\AppData\Local\Android\android-sdk\tools\ant
  • I can also open the AVD Manager and start an emulator

Even though I think I installed everything correctly and read all forum posts regarding this error I still can not seem to be able to fix this and launch my sketch on my android device. I'm constantly getting the error shown below:

BUILD FAILED C:\Users\ygruner\AppData\Local\Android\android-sdk\tools\ant\build.xml:716: The following error occurred while executing this line: C:\Users\ygruner\AppData\Local\Android\android-sdk\tools\ant\build.xml:730: Error running javac.exe compiler

Total time: 0 seconds

has anyone an idea on how to fix this problem?


APwidget is not working with processing 3.x?

$
0
0

Hi, The sketch crashes, when I run it on processing 3.0.1. It used to perfectly work with processing 2.2.1. So is it due to processing 3? Thanks in advance. Help/comment appreciated.

Vibration in processing Android

$
0
0

Hello,

I'm trying to run this code in Processing Android (processing 3.0.1, SDK 19)

// Vibrate Android via Processing
// Eric Pavey - www.akeric.com - 2010-10-24
// You must enable VIBRATE in Android -> Sketch Permissions menu!!!

// Imports:
import android.view.MotionEvent;

import android.content.Context;
import android.app.Notification;
import android.app.NotificationManager;

// Setup vibration globals:
NotificationManager gNotificationManager;
Notification gNotification;
long[] gVibrate = {0,250,50,125,50,62};
Context ctx;
void setup() {
  size(displayWidth, displayHeight);
}

void draw() {
  // do nothing...
}

//-----------------------------------------------------------------------------------------
// Override the parent (super) Activity class:
// States onCreate(), onStart(), and onStop() aren't called by the sketch.  Processing is entered
// at the 'onResume()' state, and exits at the 'onPause()' state, so just override them as needed:

void onResume() {
  super.onResume();
  // Create our Notification Manager:
  gNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
  // Create our Notification that will do the vibration:
  gNotification = new Notification();
  // Set the vibration:
  gNotification.vibrate = gVibrate;
}

//-----------------------------------------------------------------------------------------
// Override the parent (super) SurfaceView class to detect for touch events:

public boolean surfaceTouchEvent(MotionEvent event) {
  // If user touches the screen, trigger vibration notification:
  gNotificationManager.notify(1, gNotification);
  return super.surfaceTouchEvent(event);
}

It used to work a few months ago, but now, I got this error:

FATAL EXCEPTION: main Process: processing.test.test_android_vibe, PID: 28363 java.lang.RuntimeException: Unable to resume activity {processing.test.test_android_vibe/processing.test.test_android_vibe.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2986) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3017) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference

It seems that I have a problem with "Context", but impossible to find a solution. I have the same problem every time I use specific Android function into Processing (GeoLocation, soundPool, ...).

csv storing a path

$
0
0

Hi, I need help with my big problem: saving and uploading of internal memory Android.

In normal mode, I use for storage. saveTable (table, "data / Table.csv");

but it does not work in android mode.

The problem comes when you need to have access to the subfolders: saveTable (table, "data / folder1 / folder2 / Table.csv");

I never found my problem. How to do it?

How do i get sound to play on the phone

$
0
0

The code below works fine in java mode, but it doesn't work in Android mode. I just want a simple code that will play a mp3 file when clicked. I'm pretty sure the problem is in the import of Minim, I'm guessing it doesn't work for Android. If that is the case what do I need to use?

import ddf.minim.*; AudioPlayer player; Minim minim;
void setup(){minim = new Minim(this);} void draw(){} void mousePressed() { player = minim.loadFile("sin1.mp3" ); player.play(); } void stop() { player.close(); minim.stop(); super.stop(); }

Problem using Ketai function savePhoto();

$
0
0

I'm making a timeLapse app for capturing photos with a 10 seconds interval, but everytime I use the savePhoto() function with a boolean the sketch crashes. Strangely, when I use the same code but with the savePhoto() inside a void mousePressed it works nicely. Here is the code and the error message below.

`/** *

Ketai Sensor Library for Android: http://KetaiProject.org

* *

<

p>Ketai Camera Features: *

    *
  • Interface for built-in camera
  • *
  • TODO: fix HACK of camera registration that currently exceptions in setup() at the moment.
  • *
  • Updated: 2012-10-21 Daniel Sauter/j.duran

*/

import ketai.camera.*;

KetaiCamera video;

Boolean shoot = false;

void setup() {

size(640, 480, P2D);

orientation(LANDSCAPE); video = new KetaiCamera(this, 640,480, 30);

println("camerasId" + video.list());

video.setCameraID(0);

video.setSaveDirectory("/storage/sdcard0/Movies/");

video.setPhotoSize(1280,720);

video.autoSettings();

}

void onCameraPreviewEvent() {

video.read();

}

void draw() {

video.start();

background(0);

if(second()%10 == 0) { shoot = true; }

if (shoot) { video.savePhoto("foto_teste.jpg");

}

}

void onSavePhotoEvent( String filename) {

video.addToMediaLibrary(filename); println("ok"); shoot = false;

}`

ERROR: Calculated camera parameters as (w,h,fps):640,480,30 Face detection supported! Using preview format: 17 Preview size: 640x480,30 Photo size: 1280x720 Calculated photo path: /storage/emulated/0/Pictures/storage/sdcard0/Movies/foto_teste.jpg Calculated photo path: /storage/emulated/0/Pictures/storage/sdcard0/Movies/foto_teste.jpg FATAL EXCEPTION: GLThread 4041 Process: processing.test.timelapse_v4_savphoto_debug, PID: 8494 java.lang.RuntimeException: takePicture failed at android.hardware.Camera.native_takePicture(Native Method) at android.hardware.Camera.takePicture(Camera.java:1266) at android.hardware.Camera.takePicture(Camera.java:1211) at ketai.camera.KetaiCamera.savePhoto(KetaiCamera.java:708) at processing.test.timelapse_v4_savphoto_debug.timeLapse_v4_savPhoto_DEBUG.draw(timeLapse_v4_savPhoto_DEBUG.java:79) 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)

How to keep screen awake in android mode?

$
0
0

I've tried a large variety of methods form other threads, and noticed the hate on WakeLocks, which judging from the way they seem to work is reasonable, but I have not been able to get flags to work, and all the android imports don't seem to do much other than add more errors.

Processing 3 builds, while processing 2 doesn't with ant

$
0
0

Hi, I'm facing this interesting issue, while there is no issue with processing 3, but with processing 2, not able to build and is throwing error as following.

BUILD FAILED /androidsdk/android-sdk-macosx/tools/ant/build.xml:716: The following error occurred while executing this line: /androidsdk/android-sdk-macosx/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.

Any one has come across this, Please let know. Thanks in advance.


Problems accessing camera/mic/geolocation on Nexus 5

$
0
0

Hi there,

I'm having trouble accessing all the stuff that needs permission (Camera, Mic, Geolocation). What I do is just launching the examples included in android-processing. Everything launches as expected but for some reason the the cam/mic does not launch. In the cam example included (see below) for example I get the screen with the text on it, but nothing happens when i tap the screen. The necessary permissions are set.

Could this be a problem with my device?

Thanks a lot!

import ketai.camera.*;

KetaiCamera cam;

void setup() {
  orientation(LANDSCAPE);
  imageMode(CENTER);
  textSize(45);
}

void draw() {

  if(cam != null && cam.isStarted())
    image(cam, width/2, height/2, width, height);
  else
    {
      background(128);
      text("Waiting for camera....touch to activate", 100, height/2);
    }
}

void onCameraPreviewEvent()
{
  cam.read();
}

// start/stop camera preview by tapping the screen
void mousePressed()
{
  //HACK: Instantiate camera once we are in the sketch itself
  if(cam == null)
      cam = new KetaiCamera(this, 640, 480, 24);

  if (cam.isStarted())
  {
    cam.stop();
  }
  else
    cam.start();
}
void keyPressed() {
  if(cam == null)
    return;

  if (key == CODED) {
    if (keyCode == MENU) {
      if (cam.isFlashEnabled())
        cam.disableFlash();
      else
        cam.enableFlash();
    }
  }
}

Change keitai library baud rate

$
0
0

Found the solution. Didnt know how to delete post.

thanks!

How to fix this ("Could not create a virtual device for the emulator")

$
0
0

I have started using processing for developing Andriod applications quite recently, I want to try using emulator, however, I couldn't. Someone, please guide me how to fix this error!

"Untitled

Bluetooth from scratch

$
0
0

hey guys i am Tushar,getting straight into topic ,guys i am new to android development ,after reading some post on bluetooth control in processing http://arduinobasics.blogspot.in/2013/03/arduino-basics-bluetooth-android.html#comment-form ,i straight away tried in processing ,guess what API 10 is no longer supported in latest processing ,besides that post was from a long time ago,i am looking to go into basics although ketai library does the job ,but i really dont like using libraries,any help will be wonderful and thanks

Writting java/android code in android mode

$
0
0

I'm making an Android app in the processing language, and would like to use android classes like editText. Unfortunately the Apwidgets library seems to be unsupported for processing 3.0.1.

So my question is: How do you write standard android code in a processing sketch? Where do I put UI XML? Where in my sketch d0 I put things like eventListeners and eventHandlers? A simple example of how to add an Android element (like a button) and use eventhandler + listener?

Sincerely me

Viewing all 941 articles
Browse latest View live