Connecting VR and Ketai Bluetooth in Android mode

edited November 2017 in Android Mode

Hi all,

I am having problems connecting VR mode and Ketai Bluetooth connectivity in Android mode. (Win10; Porcessing 3.3.5; Android 6.0.1; Samsung S5 Neo). Independently code for Ketai bluetooth works:

import processing.vr.*;
import android.content.Intent;
import android.os.Bundle;
import ketai.ui.*;

PFont fontMy;
KetaiBluetooth bt;
String info = "";

// The following code is required to enable bluetooth at startup.

void onCreate(Bundle savedInstanceState) {
 bt = new KetaiBluetooth(this);
 println("Creating KetaiBluetooth");

void onActivityResult(int requestCode, int resultCode, Intent data) {
 bt.onActivityResult(requestCode, resultCode, data);


void setup() {
  size(displayWidth, displayHeight, P3D);  
  //start listening for BT connections and connect to a device.
  //font size
  fontMy = createFont("SansSerif", 40);

void calculate() {

void draw() {
  translate(width/2, height/2);
  // Green box, Y axis 
  translate(0, 200, 0);
  fill(0, 255, 0);
  // text from Bluetooth
 // info = "abc\ndef"; //debugging
  text(info, 20, 104);

void onBluetoothDataEvent(String who, byte[] data) {
  info = new String(data);

Everything connects nicely to my HC-05 and gets the info, and prints it next to the green box. But then I decide to add VR functionality, and everything goes wrong. So I un-comment //fullScreen(STEREO); and comment
size(displayWidth, displayHeight, P3D);, and change Android mode from "App" to "VR". The build is successful, but the app crashes and I get the following error:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean' on a null object reference at processing.test.test2.test2.setup( at processing.core.PApplet.handleDraw(Unknown Source) at processing.vr.PSurfaceVR$AndroidVRStereoRenderer.onDrawEye(Unknown Source) at Method) at$2500( at$RendererHelper.onDrawFrame( at$GLThread.guardedRun( at$ handleDraw() called before finishing

The VR-code will work nicely, if I comment the bt.start();and bt.connectDevice("00:14:03:06:37:0E");

Is it normal? Can Ketai work with In-built Processing Arduino VR Mode at all?



  • edited February 14 Answer ✓

    I managed to get vr and ketai bluetooth working by simply declaring the kt variable in setup().

    void setup() { fullScreen(STEREO); bt = new KetaiBluetooth(this); bt.start(); ... }

    I did not need the onCreate() and onActivityResult() routines.

    (Linux Mint 18.2; Processing 3.3.6; Android mode 4.0.1; Huawei P7, P9)

  • Cool! Thanks

Sign In or Register to comment.