Installed Apps Crashes using Processing 4.2 Android Mode

Though those codes worked in processing 3 before

The syntax may have changed; I doubt that it has anything to do with Processing.

Addendum:
It runs without error on my Mac once all the errors are either fixed or Remmed out.

I already gave up on the Android Dev using processing 4 using Bluetooth applications, processing android is unstable for me, it does not work on old codes most of the time.

Though I thank you for your responses, much appreciated.

processing android is unstable for me, it does not work on old codes most of the time.

I am fairly confident that the problem is in the code and not in Processing Android mode, not withstanding the fact that the last release had some issues. The code that you posted appeared to be old boilerplate code that needed to be updated. It was hard-coded to connect to a certain device so there is no way anyone else could fully test it on their system. In general Android bluetooth programming is not easy, but for me Android mode in Processing is much easier than the alternatives.

That is why I am trying to convert it to a PC based system, not using android mode.

Don’t get me wrong, I also like Android, which is why I still use it, but when it comes to Bluetooth connectivity, there are always deprecated codes, and when processing updates while codes in Bluetooth Android become deprecated, codes always keep on being updated. Unfortunately, Java mode can’t be used in mobile phones, though if it is possible to use, please let me know.

Thank you

It’s the Android code that becomes ‘deprecated’ first. The folks who are kind enough to write the editor are just trying to keep up (it’s no different in any other language). That project that you had should be fixable by updating the source code. For example, functions that used to return a byte now return a byte array. I made those changes and your code ran without error, except for the fact that it really didn’t do anything on my system because you had it hard-coded to some server or device somewhere. Furthermore, it’s a mystery what is on the other end; there was no Arduino code posted. If you want to try and fix it then we’re willing to help, but you are going to have to give us more information than you have.

Java mode can’t be used for Android mobile devices as far as I know. Android has its own way of doing things. No big deal, you just have to learn the language. It is possible to use some java code (but not all) on an Android device.

If you really want to learn Android bluetooth communication then I would suggest starting with something really simple then gradually increasing the complexity as you learn.

The code I sent here has all the information, the only difference is the App should run when connected to Bluetooth… The problem with Android mode is there is no library for it in processing, unlike in Java mode or pc based. For example in Java mode, pc based, we can use import processing.serial.*. In Android mode, there is no such thing. So my only issue with Android mode in processing is when the need of Bluetooth communication is needed.

By the way, the error in using the return byte did not appear on my end using Android mode.

the only difference is the App should run when connected to Bluetooth

Bluetooth is for serial communication; it connects an Android device to some other device wirelessly. What does the code that you posted connect to? Commonly it connects to an Arduino.

There is boilerplate code for Android bluetooth communication and that’s usually what you use. There are a series of steps that will find a device to connect to and then create a socket and connect to it.

It connects to an Arduino device via HC-06 Bluetooth.

Is P5.js feasible in connecting Arduino Uno via HC-06, have not tried it though. If this would be possible connecting both pc and mobile phone via Internet.

It connects to an Arduino device via HC-06 Bluetooth.

You did not post the Arduino code (which is necessary for testing).

Is P5.js feasible in connecting Arduino Uno via HC-06

There is a utility app called P5SerialControl which will facilitate serial connections. I’ve used it once or twice but otherwise don’t have much experience with this. Source code is here: https://github.com/p5-serial/p5.serialport

the error in using the return byte did not appear on my end using Android mode.

I just tried running your bluetooth code again from the original post (the first time I scraped it out of the e-mail post, this time it was formatted correctly) and this time it ran without errors. Below is what I see on an Android tablet; the app does nothing. There is no interface.

Oh, I forgot…

This is the Arduino Code:

#include <SoftwareSerial.h>

#define RxPin 4
#define TxPin 2
#define DEBUG_ENABLED 1

SoftwareSerial BTSerial(RxPin, TxPin);

char val;

void setup()
 {

   pinMode(RxPin, INPUT);
   pinMode(TxPin, OUTPUT);
   
   BTSerial.begin(9600);
 }
 
void loop() {
  if (BTSerial.available());
    {
    val = BTSerial.read()
    }
    delay(20);
}

It connects to HC-06, it is only used to test connectivity

Ok thank you, I will try this too.