0

I'm new in the world of Java and Android and I'm developing an android app.

The app connects a tablet with a non-android device(medical) by Bluetooth and It has to show the information on the screen.

The problem is that I dont know how to understand the information I receive, because I dont know how the device is sending the inf, lenght of byte stream, etc.

Bassed on the BluetoothChat sample I've tried with:

byte[] buffer = new byte[1024];
int bytes= mmInStream.read(buffer);
message = new String(buffer,0,bytes);

And finally when I show the message it has no sense;

Note: The information should be numbers, and maybe some words, but I think that it just sends numbers.

ppaulojr
  • 3,579
  • 4
  • 29
  • 56
  • Get the metadata/content type of the inputstream, and you will see the type of the file/data being sent. – Nikola Despotoski Sep 04 '13 at 14:44
  • I dont have it, but thx – user2747294 Sep 05 '13 at 13:04
  • It seems you do not understand the difference between a number, an encoding of a number as a sequence of bytes, a number and its text representation and the text representation of a number and the encoding of that text as a sequence of bytes. – Raedwald Apr 10 '15 at 12:07
  • possible duplicate of [What is character encoding and why should I bother with it](http://stackoverflow.com/questions/10611455/what-is-character-encoding-and-why-should-i-bother-with-it) – Raedwald Apr 10 '15 at 12:07

1 Answers1

4

You can't. If you are just receiving a long list of bytes and have no idea what it means, the best you could possibly do is just write out the byte values in hex or decimal. You need to find out what the format of the output stream is to make any use of it.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152