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

ANDROID MODE 4+ support to Keitai camera, or other ways to access camera?

$
0
0

Hey, how is it going?

Im working on an app that needs to get videos from the mobile`s camera in real time. Before downloading version 4+ of android mode it was working fine, but I had to get 4+ because its gonna be a virtual reality (cardboard) app.

I was using android 7.0 (API 24) and it was working, i could access the camera using the CameraGettingStarted from ketai, but the recommended android SDK for android mode 4+ is the 6.0 (API 23) and since ive installed it the example doesnt work, it crashes when I click to start the camera. One thing ive noticed is that it doesnt crash until i click, so i tried putting the line:

cam = new KetaiCamera(this, width, height, 24);

inside setup, and then it crashes when it starts, suggesting that this is the part when something wrong happens.

Anyone tried accessing camera using the same android mode and sdk versions? Any suggestions?

One other solution would be getting the images from the camera without the library, but I have no idea how to do that.

Basically i need to get the camera in real time to do some image processing to the frames and display them. Here`s an example code, what i get is: gray screen with "Waiting for camera....touch to activate" working with cardboard features, when i click the screen it crashes, if i put that line on setup it crashes when it starts. Its basically the getting started example from ketai with cardboard added

import processing.cardboard.*;
import ketai.camera.*;

KetaiCamera cam;

void setup() {
  fullScreen(PCardboard.STEREO);
  orientation(LANDSCAPE);
  imageMode(CENTER);
  textSize(45);

  //cam = new KetaiCamera(this, 640, 480, 24); //this is the line that crashes when app starts if not commented
}

void draw() {
  background(0);
  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();
    }
  }
}

any tips or ideas welcome! thanks in advance!


I don't see background mode ...

$
0
0

Hi , I'm looking for how to create a background app but I can't because I don't see background mode or something like that :( Where it's suposed to be ?

How can I load an image onto the tablet as an animated wallpaper?

$
0
0

I am trying to make an animated wallpaper for my Samsung Galaxy Tab A6 running Android 5.1. When I launch the code and try to set it as my wallpaper, I get the error: "Unfortunately, PongWallpaper has stopped." I was trying to debug and found that it only gives me this error when I try to load an image. The Processing shapes that I have coded run fine. The images that I am trying to load are in a folder called "Sprites" inside the sketch folder.

PImage AndroidApple, Arduino, Atari, Google, Python, RaspPi, Windows;
PImage[] ImgLineup = new PImage[7];
int currentImg = 0;
float lastImgTime;

Ball ball;
Paddle redPaddle, bluePaddle;
float[] paddleSpeeds = {-5, 5};
float[] ballSpeeds = {-5, 5};
int[] YesOrNoChoice = {0,1};

boolean CanHitRed = true, CanHitBlue = true;

color white = color(255, 255, 255);
color black = color(0, 0, 0);
color gold = color(255, 217, 84);
color red = color(255, 109, 84);
color blue = color(84, 132, 255);

void setup() {
  fullScreen();
  rectMode(CENTER);
  imageMode(CENTER);

  // images
  AndroidApple = loadImage("Sprites\\AndroidApple.png");
  Arduino = loadImage("Sprites\\Arduino.png");
  Atari = loadImage("Sprites\\Atari.png");
  Google = loadImage("Sprites\\Google.png");
  Python = loadImage("Sprites\\Python.png");
  RaspPi = loadImage("Sprites\\RaspPi.png");
  Windows = loadImage("Sprites\\Windows.png");

  AndroidApple.resize(width/2, height/2);
  Arduino.resize(width/4, height/2);
  Atari.resize(width/2, height/2);
  Google.resize(width/4, height/2);
  Python.resize(width/4, height/2);
  RaspPi.resize(width/4, height/2);
  Windows.resize(width/4, height/2);

  ImgLineup[0] = AndroidApple;
  ImgLineup[1] = Arduino;
  ImgLineup[2] = Atari;
  ImgLineup[3] = Google;
  ImgLineup[4] = Python;
  ImgLineup[5] = RaspPi;
  ImgLineup[6] = Windows;

  lastImgTime = millis();
  /////////////////////////////////////////////////////////////////

  ball = new Ball (width/2, height/2, 5);
  redPaddle = new Paddle (width/8, height/2, paddleSpeeds[floor(random(0,2))], red);
  bluePaddle = new Paddle (width - (width/8), height/2, paddleSpeeds[floor(random(0,2))], blue);
}

void draw() {
  drawGameBoard();

  if (millis() - lastImgTime >= 5000) {
    changeImg();
    lastImgTime = millis();
  }
  image(ImgLineup[currentImg], width/2, height/2);

  ball.checkPos();
  ball.drawBall();
  ball.animate();

  redPaddle.drawPaddle();
  redPaddle.checkPos();
  redPaddle.checkCollRed(ball);
  redPaddle.chooseDirRed();
  redPaddle.animate();

  bluePaddle.drawPaddle();
  bluePaddle.checkPos();
  bluePaddle.checkCollBlue(ball);
  bluePaddle.chooseDirBlue();
  bluePaddle.animate();
}

void drawGameBoard() {
  background(black);
  for(int i = 0; i <= height; i+=50) {
    fill(white);
    stroke(white);
    rect(width/2 - 5, i, 10, 40);
  }
}

void changeImg() {
  if (currentImg <= 5) {
    currentImg += 1;
  } else {
    currentImg = 0;
  }
}

class Ball {
  float xpos, ypos, speed, xSpeed, ySpeed, lastGoalTime;
  int BallWidth, BallHeight;
  Ball (float xpos, float ypos, float speed) {
    this.xpos = xpos;
    this.ypos = ypos;
    this.speed = speed;
    this.xSpeed = this.speed;
    this.ySpeed = -this.speed;
    this.BallWidth = width/32;
    this.BallHeight = BallWidth;
  }

  void drawBall() {
    fill(gold);
    stroke(gold);
    ellipse(this.xpos, this.ypos, this.BallWidth, this.BallHeight);
  }

  void animate() {
    this.xpos += this.xSpeed;
    this.ypos += this.ySpeed;
  }

  void checkPos() {
    // check for 'CanHit' variables
    if (this.xpos > width/2) {
      CanHitRed = true;
    }
    if (this.xpos < width/2) {
      CanHitBlue = true;
    }

    if (this.xpos <= 0 || this.xpos >= width) {
      // stop the ball's speed
      this.xSpeed = 0;
      this.ySpeed = 0;
      // bring the ball back to the center of the screen
      this.xpos = width/2;
      this.ypos = height/2;
      // find the time
      this.lastGoalTime = millis();
    }

    if (this.ypos <= 0 || this.ypos >= height) {
      this.ySpeed = -this.ySpeed;
    }

    if (this.xSpeed == 0 && this.ySpeed == 0) {
      if (millis() - this.lastGoalTime >= 2000) {
        this.xSpeed = ballSpeeds[floor(random(0,2))];
        this.ySpeed = ballSpeeds[floor(random(0,2))];
      }
    }

  }

}

class Paddle
{
  float xpos, ypos, speed, upSpeed, downSpeed, lastDirTime;
  float PaddleWidth, PaddleHeight;
  color paint;
  Paddle (float xpos, float ypos, float speed, color paint) {
    this.xpos = xpos;
    this.ypos = ypos;
    this.speed = speed;
    this.upSpeed = -speed;
    this.downSpeed = speed;
    this.lastDirTime = millis();
    this.paint = paint;
    this.PaddleWidth = width/32;
    this.PaddleHeight = height/8;
  }

  void drawPaddle() {
    fill(this.paint);
    stroke(this.paint);
    rect(this.xpos, this.ypos, this.PaddleWidth, this.PaddleHeight);
  }

  void animate() {
    this.ypos += this.speed;
  }

  void checkPos() {
    if (this.ypos <= 0 || this.ypos >= height) {
      this.speed = -this.speed;
    }
  }

  void checkCollRed(Ball ball) {
    if (CanHitRed == true) {
      if ( (ball.xpos - ball.BallWidth/2) <= (this.xpos + this.PaddleWidth/2) && (ball.xpos + ball.BallWidth/2) >= (this.xpos - this.PaddleWidth/2) &&
      (ball.ypos + ball.BallHeight/2) >= (this.ypos - this.PaddleHeight/2) && (ball.ypos - ball.BallHeight/2) <= (this.ypos + this.PaddleHeight) ) {
        ball.xSpeed = -ball.xSpeed;
        ball.ySpeed = -ball.ySpeed;
        CanHitRed = false;
      }
    }
  }

  void checkCollBlue(Ball ball) {
    if (CanHitBlue == true) {
      if ( (ball.xpos + ball.BallWidth/2) >= (this.xpos - this.PaddleWidth/2) && (ball.xpos - ball.BallWidth/2) <= (this.xpos + this.PaddleWidth/2) && (ball.ypos + ball.BallHeight/2) >= (this.ypos - this.PaddleHeight/2) && (ball.ypos - ball.BallHeight/2) <= (this.ypos + this.PaddleHeight) ) {
        ball.xSpeed = -ball.xSpeed;
        ball.ySpeed = -ball.ySpeed;
        CanHitBlue = false;
      }
    }
  }

  void chooseDirRed() {
    if ( millis() - this.lastDirTime >= 10000 ) {
      if ( YesOrNoChoice[floor(random(0,2))] == 1 ) {
        this.speed = -this.speed;
        this.lastDirTime = millis();
      }
    }
  }

  void chooseDirBlue() {
    if ( millis() - this.lastDirTime >= 8000 ) {
      if ( YesOrNoChoice[floor(random(0,2))] == 1 ) {
        this.speed = -this.speed;
        this.lastDirTime = millis();
      }
    }
  }

}

2D elements within Cardboard

$
0
0

Hi,

I'm trying to use the Cardboard library for a 2D project. Although this might not be common, I assumed there would be a way to include 2D elements in a Cardboard sketch, such as an info overlay, and things like that. I tried using hint(DISABLE_DEPTH_TEST), which works in other scenarios, but it still prints elements within the 3D space.

Am I missing something or is that not possible? Thanks

How do I move an existing processing project to android studios?

$
0
0

How do I move an existing processing project to android studios?

Processing 4, Android Wallpaper Settings activity ?

$
0
0

Hi guys, Can anyone tell me if it is possible to add a settings activity to the live wallpaper section ? I tried few things but it seems quite messy to add a class in processing and referencing a xml template like in pure android... Any help ? Advice ? Cheers !

Getting an Access error with PrintWriter

$
0
0

I have a PrintWriter object named fileOut which I initialize with createWriter("testfile.txt"). I then print to it, flush and close it.

It will not compile, repeatedly giving me two of these errors:

check = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Manifest.permission.READ_EXTERNAL_STORAGE cannot be resolved

I have both READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE enabled properly.

Anyone experience this before?

How to install android mode 4 ?

$
0
0

Hi all !

I want to install "android mode 4" for cardboard and live wallpaper , How can I do ??? :(

Thanks !


Intermittent broken colours with android live wallpaper

$
0
0

I was wondering if someone has encountered a similar problem to what I have. I have created a simple live wallpaper (starfield effect) and most of the time it works fine on my android 7 device and other devices the problem appears more often.

When previewing the wallpaper it is always rendered correctly but after applying and going back to the home screen the stars will be drawn black. I have tried drawing large static boxes and ellipses on the screen with static colours like red, blue etc but they are also drawn black. The stars are also large like stroke has been enabled even though I have set to noStroke.

On an older M8 (android 5.01) It happens consistently but if I set the wallpaper so its not working and then simply rerun the sketch it will correct it and it will run fine until the phone is restarted or wallpaper is reselected. My android 7 phone will fix the problem with a restart.

Serial communication between Android and PC?

$
0
0

Didn't want to ask this because there is a lot of stuff out there on this topic, but I just can't seem to get it working. The main tutorial I've followed can be found here.

I've installed AndroidSerial, exported my project as a signed package, added the device filter lines in AndroidManifest.xml, created the xml directory in the res directory, and copied device_filter.xml into it, but when I try to build it it throws "Error: No resource found that matches the given name (at 'resource' with value '@xml/device_filter')."

I just want to send readable data from my phone to the PC, it doesn't seem like it should be this complicated especially considering it already has built-in console debugging with print()... Any ideas?

Has anyone been able to graph multivariable real time data from bluetooth com port?

$
0
0

I have started making a project with a SAM MCU from Atmel that once every second transmits the state of the various components involved through a bluetooth connection using the MCU's com port. Has anyone been able to make an app that will take comma separated data coming in on its bluetooth serial connection and plot it real time on an android?

APDE on a chromebook thanks to recent changes to chromeOS?

$
0
0

Hi internet, There was a recent change to chromeOS to allow android apps to function on chromebooks. I was curious if you know of anyone who has tried to use processing for android to get the IDE working on a chromebook. Seems like that would be much simpler than the alternative. thanks in advance, Chris

Vector copying in Android Mode

$
0
0

Hi,

I have a class that is passed a PVector in the constructor, which it then assigns to a variable using the .copy() function. However, in the console I get this error: this.velocity = _velocity.copy(); ^^^^ The method copy() is undefined for the type PVector

Can anyone help?

Thanks

Importing admob sdk into processing

$
0
0

I've been trying to get ads working on my processing app with multiple guides found on here, but I can't seem to get the library imported properly. I have the following imports in my sketch

import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.widget.RelativeLayout;
import com.google.ads.*;

but I only get "The import com.google cannot be resolved". I've understood that I need to copy the needed library somewhere for processing to use, but haven't gotten any combination to work. I'm working on the processing environment, do I need to set up Eclipse for this?

So in short i just need to know where to find the right .jar and where to place it

Why is everything an error?

$
0
0

Hi,

In my processing sketch in Android mode, everything appears to be underlined in red. The code runs fine, but why does this happen?


Live wallapper android mode 4+

$
0
0

I manually installed the android mode-0256 from Gitub, and then I wrote a very simple code and run it on my phone as this tutorial shows http://android.processing.org/tutorials/wallpapers/index.html I eaven ticked "wallapper" under the android menu in the processing IDE, and finally run the code to install the sketch on my huawei p8 lite 2017. The problem is that the icon of the sketch doesn't appear in the wallapper selector, and if i try to open it from the list of all installed apps appear a message which say "impossible to open". What can i try to do to set the sketch as my home live wallaper? Thank you

What is an Android app beneficial for Business

$
0
0

Hi. Friends, how are you. I am here for asking a question that how android applications are useful for my business. Can I connect with my customers using Android app.

How to learn processing Android

$
0
0

Hi, I do not want to become a professional Android Application developer, but i am hobbyist trying to build new things associated with my electronics project. I have learnt how to use processing to make some basic applications using Bluetooth. Now I want to proceed a bit further I found this program here : http://android.processing.org/tutorials/location/index.html

but, i am nat able to understand anything much of it. I have some decent coding skills on C program and other embedded programs but a complete novice in JAVA.

What should be my next step? Is there any other way rather than just starting with Android Studio

Live wallapper selector for android

$
0
0

I have coded several live wallappers with processing, but my problem is that now I'have all these wallappers installed separately on my mobile. Is it possible to create an android app (with processing, because i have no experiences of android development) from which i can select and set the live wallapper i like most? If processing is able to do this, can you give me some links or some advice? Thanks

How to adjust the application name in Android processing?

$
0
0

Application name which is located under the icon is same with the project name. But I want to change that without changing the project title. Does anyone know how to do that?

Viewing all 941 articles
Browse latest View live