APDE ketai example

Hi this code receive data from terminal but not sending what I missed ?

import android.content.Intent;
import android.os.Bundle;
import ketai.net.bluetooth.*;
import ketai.ui.*;
import ketai.net.*;

PFont fontMy;
boolean bReleased = true; //no permament sending when finger is tap
KetaiBluetooth bt;
boolean isConfiguring = true;
String info = "";
KetaiList klist;
ArrayList devicesDiscovered = new ArrayList();

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

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

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

void setup() {
 size(displayWidth, displayHeight);
 //start listening for BT connections
 //at app start select device…
 isConfiguring = true;
 //font size
 fontMy = createFont("SansSerif", 40);

void draw() {
 //at app start select device
 if (isConfiguring)
  ArrayList names;
  background(78, 93, 75);
  klist = new KetaiList(this, bt.getPairedDeviceNames());
  isConfiguring = false;
  if((mousePressed) && (bReleased == true))
 //send with BT
  byte[] data = {'s','w','i','t','c','h','\r'};
 //first tap off to send next message
  bReleased = false;
  if(mousePressed == false)
  bReleased = true; //finger is up
 //print received data
  text(info, 20, 104);

void onKetaiListSelection(KetaiList klist) {
 String selection = klist.getSelection();
 //dispose of list for now
 klist = null;

//Call back method to manage data received
void onBluetoothDataEvent(String who, byte[] data) {
 if (isConfiguring)
 info += new String(data);
 //clean if string to long
 if(info.length() > 150)
 info = "";


I read it so it must be working! :)

Thanks for updating original post with more details.

1 Like


:grinning: :grinning:

working one way just receiving


I tried your code with the Arduino serial monitor and it is sending and receiving.

When I touch Android screen the Arduino serial monitor receives “switch”.
When I type in text and send it with the Arduino serial monitor I receive it on the Android display.

I find the Arduino monitor handy for quick testing… not as configurable as other terminal emulators but works!


I sent this with Arduino serial monitor to Android:

1 Like


when i did not receive on terminal i felt lazy to try other way

i am going to walk on your steps thanks for response

1 Like


I am not an expert with Android Processing…
I mostly just come here to dabble with and help others where I can.
I enjoy the challenge.

Stay well!


1 Like

You are making special effort, may God bless you and thank you for your time

1 Like