Hello,
I tried in every Way to disable The back button during The executin of my app, But without success. Riace somme to help me? Thank You Very much forse helping
Hello,
I tried in every Way to disable The back button during The executin of my app, But without success. Riace somme to help me? Thank You Very much forse helping
A couple of months ago I made the following post, about how to get sound to play.
https://forum.processing.org/two/discussion/comment/53262
@akenaton was extremely helpful, and helped me get sound to play on my phone. Now I'm ready to take the program to the next level. Eventually I want to make an app to help me learn Cantonese. Right now I'm just trying to make a program that will play 6 different sound files, depending on what button is pressed. Each file is a mp3 and is only one word, so its about 1 second long.
the code below runs fine in java mode:
Button[] b;
import ddf.minim.*;
Minim minim;
void setup() {
// size(1080,1920);//phone res
size(360, 640);// 1/3 of phone res
minim = new Minim(this);
rectMode(RADIUS);
b= new Button[6];
b[0] = new Button(width/6, height-width/6, "sin1.mp3");
b[1] = new Button(3*width/6, height-width/6, "sin2.mp3");
b[2] = new Button(5*width/6, height-width/6, "sin3.mp3");
b[3] = new Button(width/6, height-3*width/6, "sin4.mp3");
b[4] = new Button(3*width/6, height-3*width/6, "sin5.mp3");
b[5] = new Button(5*width/6, height-3*width/6, "sin6.mp3");
//there are 6, 1 second, mp3 files in the folder with the project.
}
void draw() {
background(255);
for (int n = 0; n < 6; n++) {
b[n].update();
}
}
//---------------------------------------------------------
//---------------------------------------------------------
//---------------------------------------------------------
class Button {
float x, y, r;
color myColor;
boolean initialPress;
String mp3;
AudioPlayer player;
Button( float myX, float myY, String myMp3) {
x=myX;
y=myY;
r=width/7;
myColor=color(200, 200, 10);
initialPress=true;
mp3=myMp3;
}
void update() {
fill(myColor);
rect(x, y, r, r);
if (mousePressed && over() && initialPress ) {//when the button is pressed (initially) , this code runs
initialPress=false;
player = minim.loadFile(mp3);
player.play();
} else if ( !mousePressed || !over()) {//when the button is NOT being pressed, this code runs
initialPress=true;
}
}
boolean over() {
float d = max(abs(x-mouseX), abs(y-mouseY)); // this is a square
return d <= r ;
}
}
</code>
I want this to run on my phone. However I learned before that Minim doesn't seem to work in android mode, and I have to use android.media.MediaPlayer instead. I'm not really sure how to even begin doing this. I tried some things before, but when I had multiple sound files in a folder the android media player would just play all files one by one. Therefor I don't even what to show you may attempt to get the android media player to work, because I know I did it all wrong.
I want to get the above code to run on my phone. PLEASE HELP
Hi everybody, I'm new to the forum (I'm Italian, sorry for my bad English). I don't know if this one is the right category, probably not... Btw, my phone has a 2k monitor and when the sketch (even a blank one) runs on it i get 50 fps maximum, i tried P2D that boosted me over the 60ish but I've got other problems with it... Is there a way to improve my fps on fullscreen app? I thought something like up scaling for PCs... Thanks for your time
Processing in Java mode use pixelDensity to change the dimension of pixel to be shown, how can i use such a thing on Android mode? my app on high density display lags and i can't solve this problem. thank you in advance. (Sorry for the bad english)
I am currently trying to build a project but need some help with the coding side of it. I am trying to make a TrailCamera that would send the pictures it takes to some online source for remote viewing. I dont even know if it is possible. But is there any way to make a program for an android phone that could send a picture over the internet to some source so that a user could view it whenever he wanted to. The picture would come from the trailcam via USB, then be sent via 3G. Im thinking a cheap android phone with a pay-as-you-go data plan. Now I just need the code to go from USB-through android-and then to the internet.
Hopefully a quick question - As APWidgets is no longer compatible with Processing, any simple way to create an on-screen "save/export" button for Android Mode? There are a few threads about creating buttons, but I cannot use mousePressed on Android, and would prefer not to use the keyboard from, for example, the Ketai library.
Hello forumers,
I am looking for tips and hints on "the best way" to approach something. I want to either import, or create, geometry (initially a cylinder), isolate half of it, and move the vertices around, then export it again as an .obj or .stl. I realise there are libraries that will do this but I need this to work on Android and the libraries (as far as I know) don't. I made these images in 3DMax to explain what I mean.

I have adapted this method for creating a cylinder from an example in the book: Processing 2: Creative Coding Hotshot...
float[][] vertx;
float[][] verty;
void setup() {
size(800, 600, P3D);
vertx = new float[36][36];//36 triangle strips, 36 vertices
verty = new float[36][36];
}
void draw() {
hint( ENABLE_DEPTH_TEST );
pushMatrix();
background(125);
fill(255);
strokeWeight(0.5);
translate( width/2, height/2, 200);
rotateX(radians(-45));
scale( 1 );
translate(0, -50, 0);
initPoints();
beginShape(TRIANGLE_STRIP );
for ( int h = 1; h < 36; h++) {
for ( int a = 0; a<37; a++ ) {
int aa = a % 36;
// normal( vertx[h][aa], 0, verty[h][aa]);
vertex( vertx[h][aa], h*5.0, verty[h][aa] );
//normal( vertx[h-1][aa], 0, verty[h-1][aa]);
vertex( vertx[h-1][aa], (h-1)*5.0, verty[h-1][aa] );
}
}
endShape();
beginShape(TRIANGLE_FAN); //bottom
int h = 35;
vertex( 0, h*5, 0 );
for ( int a = 0; a<37; a++ ) {
int aa = a % 36;
vertex( vertx[h][aa], h*5, verty[h][aa] );
}
endShape();
popMatrix();
hint(DISABLE_DEPTH_TEST);
}
float getR( float a, float h ) {
float r = 50;
return r;
}
void initPoints() {
for ( int h = 0; h < 36; h++) {
for ( int a = 0; a<36; a++) {
float r = getR( a*10.0, h*5.0 ); //a = 10 (360/36)
vertx[h][a] = cos( radians( a*10.0 )) * r;
verty[h][a] = sin( radians( a*10.0 )) * r;
}
}
}
...and I am assuming it is possible to isolate/grab certain vertices from the array?
Any other approaches, or any advice on how to develop this? Is the import > transform method even possible?
I am currently porting my Classic Bluetooth System to the new BLE.
Previouly, I was using KETAI library to access Bluetooth communication on my Android Device so it can communicate with my Arduino Uno with a HC-05 Bluetooth module. Everything worked well.
Now, I am using Bluefruit LE Micro (by Adafruit, An arduino-compatible chip with BLE from Nordic)
I am having troubles with the Bluetooth Low Energy side of this module.
I have found a library called BLEPDROID on github that utilizes Bluetooth low energy and Processing together with RFDuino but the library does not provide adequate tutorial on how to use their codes. I am not an expert when it comes to understanding codes so it is quite difficult for me.
If someone can guide me through their Library that would help OR if you can suggest a better library or way for me to understand how to code with BLE that would also help.
How to I can make a webserver for android. And How to I can use this codes in processing file. http://developer.android.com/samples/PermissionRequest/src/com.example.android.permissionrequest/SimpleWebServer.html
Hi, I´ve made an sketch and run it in android mode with an emulator. It works. I´ve exported it as an android project, and it creates a folder with many files and subfolders. But what I need is an apk file to install in my device. How do I get it?
Hi, I have a project on processing bluetooth android ( version221 ) with a slider control. But The conversion method intToByteArray () does not work in void COMMANDE (Slider).
Processing code is:
import android.content.Intent; import android.os.Bundle; import ketai.net.bluetooth.*; import ketai.ui.*; import ketai.net.*;
import controlP5.*; // Importe la librairie GUI controlP5
PFont fontMy; boolean bReleased = true; //Pas de changement d'état de la réponse si le doigt reste appuyé sur l'écran. KetaiBluetooth bt; boolean isConfiguring = true; String info = ""; KetaiList klist;
ControlP5 controlP5; // déclare un objet principal de la librairiecontrolP5
Button boutton; Slider slider; int valeur; byte [] a; byte [] b;
//******************************************************************** //Liaison Bluetooth //********************************************************************
void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); bt = new KetaiBluetooth(this); }
void onActivityResult(int requestCode, int resultCode, Intent data) { bt.onActivityResult(requestCode, resultCode, data); }
void setup() { size(displayWidth, displayHeight); frameRate(10); orientation(PORTRAIT); background(0);
//Début de connexion Bluetooth. bt.start(); //Sélection de l'application. isConfiguring = true; //Couleur de fond fontMy = createFont("SansSerif", 40); textFont(fontMy);
controlP5 = new ControlP5(this); // Initialise l'objet principal de la librairie controlP5.
boutton = controlP5.addButton("BOUTON",0,150,525,200,100);
slider = controlP5.addSlider("COMMANDE",0,255,127,20,50,360,30); // ajoute un Slider au ControlP5 slider.setNumberOfTickMarks(256); slider.showTickMarks(false); slider.setDecimalPrecision(0);
}
void draw() { //Si la sélection de l'application est valide. if (isConfiguring) { klist = new KetaiList(this, bt.getPairedDeviceNames()); isConfiguring = false; } else { background(0,50,0); } //Affichage de la reception des données. fill(204); noStroke(); textAlign(LEFT); text(info, 20, 104); }
void onKetaiListSelection(KetaiList klist) { String selection = klist.getSelection(); bt.connectToDeviceByName(selection); //Présence d'une Liste. klist = null; }
//Méthode de gestion des évenements (dans la librairie Ketai), permettant de recevoir les données. void onBluetoothDataEvent(String who, byte[] data) { if (isConfiguring) return; //Réception. info += new String(data); //Effacer si le mot trop long. if(info.length() > 150) info = ""; }
void BOUTON() { // fonction évènement Button de meme nom - reçoit la valeur byte[] data = {'v','\n'}; bt.broadcast(data); bReleased = false; println(data); }
void COMMANDE( int valeur) { // fonction évènement Slider de meme nom - reçoit la valeur
byte[] a= intToByteArray(valeur); // excellent function for converting int to byte array (byte[]) which is what the Ketai bluetooth
//library sends.
byte[] b={'q'}; // sending the 'q' character as a byte[]
bt.broadcast(b); // send identifier character
bt.broadcast(a); // send (broadcast) the bluetooth slider info
println("Evènement Slider PWM avec valeur = "+valeur); // message console Processing - debug
delay(10); // entre 2 prises en compte }
Processing android tells me the following error: The method intToByteArray(int) is undefined for the type
Does anyone have an idea to help me? Thanks.
I'm trying to run this 3d sphere viewer on Android and am getting openGL errors.
This is the error I get.
Already called drawing on another PGraphicsOpenGL object FATAL EXCEPTION: GLThread 202 Process: processing.test.eqviewer, PID: 2258 java.lang.NullPointerException at processing.opengl.PGraphicsOpenGL.setFramebuffer(Unknown Source) at processing.opengl.PGraphicsOpenGL.beginPixelsOp(Unknown Source) at processing.opengl.PGraphicsOpenGL.readPixels(Unknown Source) at processing.opengl.PGraphicsOpenGL.loadPixels(Unknown Source) at processing.test.eqviewer.EqViewer.setup(EqViewer.java:81) at processing.core.PApplet.handleDraw(Unknown Source) at processing.opengl.PGL$AndroidRenderer.onDrawFrame(Unknown Source) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
The code works great in JAVA mode on OSX.
Any ideas?
Thanks.
Phil
public boolean showlight = false;
PGraphics portal;
PImage gp;
public boolean viewwin= false;
public boolean autorotate = false;
import processing.opengl.*;
PImage bg;
PImage texmap;
PGraphics pop;
PImage mmget;
int sDetail = 175; //Sphere detail setting
float rotationX = 0;
float rotationY = 0;
float velocityX = 0;
float velocityY = 0;
float globeRadius = 300;
float pushBack = 0;
public float rotation = 0.0f;
float[] cx,cz,sphereX,sphereY,sphereZ;
float sinLUT[];
float cosLUT[];
float SINCOS_PRECISION = 0.5f;
int SINCOS_LENGTH = int(360.0 / SINCOS_PRECISION);
public String [] file;
//
void setup()
{
file = new String[9];
file[0] = "vr.jpg";
mmget = new PImage (255,255);
if (texmap == null){
size(640, 480, P3D);
texmap = loadImage (file[0]);
}
// smooth();
pop = createGraphics(width,height,P3D);
pop.beginDraw();
loadPixels();
portal = createGraphics(width,height,P3D);
portal.beginDraw();
portal.loadPixels();
if (texmap !=null){
portal.image(texmap,0,0,width,height);
portal.endDraw();
portal.updatePixels();
pop.loadPixels();
pop.image(texmap,0,0,width,height);
pop.updatePixels();
}
initializeSphere(sDetail);
gp = new PImage (640,480);
noStroke();
gp.loadPixels();
}
int x,y,i,w=512;
int r(int a){return int(random(a));}
void draw()
{
background(0);
rotation +=.02;
translate(width/2,height/2, 300);
//rotateY(radians(180)); // uncomment to look ahead
if (autorotate){
rotateY(rotation);
}
renderGlobe();
if (viewwin){
for (int x= 0;x<width;x++){
for (int y= 0;y<height;y++){
set (x,y,portal.pixels[x+width*y]);
}
}
}
}
void renderGlobe()
{
pushMatrix();
//translate(width/2.0, height/2.0, pushBack);
pushMatrix();
noFill();
stroke(255,200);
strokeWeight(2);
//smooth();
popMatrix();
lights();
pushMatrix();
rotateX( radians(-rotationX) );
rotateY( radians(270 - rotationY) );
fill(200);
noStroke();
textureMode(IMAGE);
texturedSphere(globeRadius,texmap);
popMatrix();
popMatrix();
rotationX += velocityX;
rotationY += velocityY;
velocityX *= 0.95;
velocityY *= 0.95;
// Implements mouse control (interaction will be inverse when sphere is upside down)
if(mousePressed){
velocityX += (mouseY-pmouseY) * 0.01;
velocityY -= (mouseX-pmouseX) * 0.01;
}
}
void initializeSphere(int res)
{
sinLUT = new float[SINCOS_LENGTH];
cosLUT = new float[SINCOS_LENGTH];
for (int i = 0; i < SINCOS_LENGTH; i++) {
sinLUT[i] = (float) Math.sin(i * DEG_TO_RAD * SINCOS_PRECISION);
cosLUT[i] = (float) Math.cos(i * DEG_TO_RAD * SINCOS_PRECISION);
}
float delta = (float)SINCOS_LENGTH/res;
float[] cx = new float[res];
float[] cz = new float[res];
// Calc unit circle in XZ plane
for (int i = 0; i < res; i++) {
cx[i] = -cosLUT[(int) (i*delta) % SINCOS_LENGTH];
cz[i] = sinLUT[(int) (i*delta) % SINCOS_LENGTH];
}
// Computing vertexlist vertexlist starts at south pole
int vertCount = res * (res-1) + 2;
int currVert = 0;
// Re-init arrays to store vertices
sphereX = new float[vertCount];
sphereY = new float[vertCount];
sphereZ = new float[vertCount];
float angle_step = (SINCOS_LENGTH*0.5f)/res;
float angle = angle_step;
// Step along Y axis
for (int i = 1; i < res; i++) {
float curradius = sinLUT[(int) angle % SINCOS_LENGTH];
float currY = -cosLUT[(int) angle % SINCOS_LENGTH];
for (int j = 0; j < res; j++) {
sphereX[currVert] = cx[j] * curradius;
sphereY[currVert] = currY;
sphereZ[currVert++] = cz[j] * curradius;
}
angle += angle_step;
}
sDetail = res;
}
// Generic routine to draw textured sphere
void texturedSphere(float r, PImage t)
{
int v1,v11,v2;
r = (r + 240 ) * 0.33;
beginShape(TRIANGLE_STRIP);
texture(t);
float iu=(float)(t.width-1)/(sDetail);
float iv=(float)(t.height-1)/(sDetail);
float u=0,v=iv;
for (int i = 0; i < sDetail; i++) {
vertex(0, -r, 0,u,0);
vertex(sphereX[i]*r, sphereY[i]*r, sphereZ[i]*r, u, v);
u+=iu;
}
vertex(0, -r, 0,u,0);
vertex(sphereX[0]*r, sphereY[0]*r, sphereZ[0]*r, u, v);
endShape(CLOSE);
// Middle rings
int voff = 0;
for(int i = 2; i < sDetail; i++) {
v1=v11=voff;
voff += sDetail;
v2=voff;
u=0;
beginShape(TRIANGLE_STRIP);
texture(t);
for (int j = 0; j < sDetail; j++) {
vertex(sphereX[v1]*r, sphereY[v1]*r, sphereZ[v1++]*r, u, v);
vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2++]*r, u, v+iv);
u+=iu;
}
// Close each ring
v1=v11;
v2=voff;
vertex(sphereX[v1]*r, sphereY[v1]*r, sphereZ[v1]*r, u, v);
vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2]*r, u, v+iv);
endShape(CLOSE);
v+=iv;
}
u=0;
// Add the northern cap
beginShape(TRIANGLE_STRIP);
texture(t);
for (int i = 0; i < sDetail; i++) {
v2 = voff + i;
vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2]*r, u, v);
vertex(0, r, 0,u,v+iv);
u+=iu;
}
vertex(0, r, 0,u, v+iv);
vertex(sphereX[voff]*r, sphereY[voff]*r, sphereZ[voff]*r, u, v);
endShape(CLOSE);
}
i'm wondering is there any method can call native camera with native menu on it my phone is sony z2,something like the picture showing.i did try with ketai camera,but it just showing the camera images without any native menu on it is that possible? cheers

Hello, why this method intToByteArray() is not active Android then it function in java?
Hello I want to use my processing code in android studio as animated background did any budy know how to do it ?
Hello, I am trying to save a picture (save() or saveFrame() to Sdcard. The file is empty. Everything works fine in Java mode.
I have enabled the permission - WRITE_EXTERNAL_STORAGE I can save .txt file but problem is with pictures. The file has 0kB size.
Here's my simply code.
import controlP5.*;
ControlP5 cp5;
PImage backgroundImg = null;
void setup()
{
size(displayWidth, displayHeight);
backgroundImg = loadImage("backImg.jpg");
backgroundImg.resize(width, height);
backgroundImg.loadPixels();
cp5 = new ControlP5(this);
cp5.addButton("savePicBut")
.setBroadcast(false)
.setPosition(30, 30)
.setSize(30,30)
.setLabel("Save")
.setBroadcast(true);
}
void draw()
{
background(backgroundImg);
}
public void savePicBut()
{
saveFrame("//sdcard/PicTest.png");
String[] words = {"test1","test2","test3"};
saveStrings("//sdcard/words.txt",words);
}
Thanks a lot for your help. Sebastian
Hi, I am making one application using Ketai library for Android. I will need to make it stereoscopic. The point is that you get an image from a camera and you see it on google cardboard, so it needs to be stereoscopic. Does anyone know any kind of library that would be helpful? I found Camera3D, but I don't know if it will be suitable. If you have any suggestions, please let me know. Thanks in advance.
I have two tablets of different OS, one Lollipop and the other Kit Kat. I am able to connect to the device on the Kit Kat OS but not the Lollipop device.
Are there any known problems with coding in Processing to read from an Arduino and running it in Android Mode?
Hi,
I'm trying to get two values as string structure from Arduino. Data coming pretty fast. (115200 baudrate - 50 ms delay) (my goal 10ms)
I would like to plot one of the values on the screen. But ploting is as the picture below.
Where is the problem? What should I do?
Thanks,
import android.content.Intent;
import android.os.Bundle;
import ketai.net.bluetooth.*;
import ketai.ui.*;
import ketai.net.*;
import oscP5.*;
KetaiBluetooth bt;
String info = "";
KetaiList klist;
float val1, val2;
//ArrayList<String> names;
int xPos = 1;
float height_old = 0;
float height_new = 0;
boolean veri = true;
float[] gelen;
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bt = new KetaiBluetooth(this);
}
void setup()
{
background(0);
bt.start();
stroke(255);
fill(0xff);
textSize(32);
if (bt.getDiscoveredDeviceNames().size() > 0)
klist = new KetaiList(this, bt.getDiscoveredDeviceNames());
else if (bt.getPairedDeviceNames().size() > 0)
klist = new KetaiList(this, bt.getPairedDeviceNames());
bt.discoverDevices();
xPos = (width/4)+1;
height_old = (height/2)-5;
stroke(0,0xff,0xff);
strokeWeight(5);
line(((width/4)-3),0,((width/4)-3),height);
line(0,(height/2),width,(height/2));
stroke(0xff, 0, 0);
strokeWeight(2);
}
void draw()
{
text(val1,50,50);
val1 = map(val1, 0, 1023, 0, (height/2)-5);
height_new = (height/2)-5 - val1;
stroke(0);
line(xPos,0,xPos,(height/2)-5);
stroke(0xff, 0, 0);
line(xPos - 1, height_old, xPos, height_new);
height_old = height_new;
if (xPos >= width) {
xPos = width/4;
}
else {
xPos++;
}
}
void onBluetoothDataEvent(String who, byte[] data)
{
info+= new String(data);
gelen = float(split(info, ' '));
val1=gelen[0];
val2=gelen[1];
println(info);
}
void onKetaiListSelection(KetaiList klist)
{
String selection = klist.getSelection();
bt.connectToDeviceByName(selection);
klist = null;
}
