I am working on an Android app in Java which writes data I receive via bluetooth to an arrayadapter to be displayed on the screen. Some of the data includes new lines and carriage returns and instead of those executing their respective operations in the arrayadapter, I instead just want to just display their literal ASCII value (\n, \r) in the arrayadapter.
Is there a natural way to do this within the Android SDK or do I need to parse the data in order to do this?
Here is the bit of code I use to set the arrayadapter:
byte[] writeBuf = (byte[]) msg.obj;
String writeMessage = new String(writeBuf);
conversationArrayAdapter.add("Me: " + writeMessage);
Thanks for any input!
You will have to escape them inside the string so they display as “\n” and “\r”, otherwise the view will iterpret the character itself; something like:
Not 100% sure of that syntax, but that’s the idea.