1

I want to send numeric data from the terminal app as a ASCII with Bluetooth to the Android app, and inside the Android app, to convert ASCII numeric data to characters.

I only found one solution, but it reads as a single byte. I wrote this command for Android app to get data:

InputStream stream;
if (stream.available() > 0) {
    int a = stream.read();
    int x = Character.getNumericValue(a);
    this.mmOutStream.write(x);
    this.mmOutStream.flush();
}

This command

int a = stream.read (); /// 128

It takes the data as a ASCII and throws it inside a

This command

int x = Character.getNumericValue(a); /// 1 2 8

ASCII converts to characters, but gives a single byte of data. That is, I give the number as a ASCII, for example, the number 128 128 to converts to 1 2 8. But I want 128, but he gives it to me one by one.

MN7272
  • 19
  • 1
  • 5

1 Answers1

1

You can cast an ASCII decimal value to char as follows:

int ch = 125;
System.out.println((char) ch); // }
System.out.println(Character.getName(ch)); // RIGHT CURLY BRACKET

See also: Why do I get a number when I add chars?