Sending multiple values from android to mega adk

Hey i successfully made this code to work

But i need to send a string from my android containing real time touch position of x and y from phone. here's my code:

 public void senddata(String message) {

//        byte[] msgBuffer = message.getBytes();
       
        if (mOutputStream != null) {
            try {
//                Log.e(TAG,msgBuffer.toString());
                mOutputStream.write(msgBuffer);
            } catch (IOException e) {
                Log.e(TAG, "write failed", e);
            }
        }


    }

and heres the code in arduino to recieve:

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
#define  LED_PIN  13
String inData;
AndroidAccessory acc("Manufacturer",
    "Model",
    "Description",
    "1.0",
    "http://yoursite.com",
                "0000000012345678");
void setup()
{
  // set communiation speed
  Serial.begin(115200);
//  pinMode(LED_PIN, OUTPUT);
  acc.powerOn();
}
 
void loop()
{
  
  byte msg[0];
  if (acc.isConnected()) {
     char recieved = acc.read(msg, sizeof(msg), 1);
//    int len = acc.read(msg, sizeof(msg), 1); // read data into msg variable
    inData += recieved;
      Serial.print("Arduino Received1: ");
            Serial.println(inData);
            inData = ""; 
    
}
}

And m just recieving "ardunio recieved: y or sometimes -1" continously.
so help plz..??? BTW my first post and thread on forum.cheers :slight_smile:

But i need to send a string from my android containing real time touch position of x and y from phone. here's my code:

There is NOTHING in that snippet that convinces me that the message being sent is anything other than "hello world".

and heres the code in arduino to recieve:

I KNOW that the example was not formatted that crappily. Why did you randomly add and/or remove tabs to make the code look like shit?

  byte msg[0];

An array that can hold nothing. How the f**k is that supposed to be useful?

     char recieved = acc.read(msg, sizeof(msg), 1);

You just shit on memory you don't own.

PaulS:
There is NOTHING in that snippet that convinces me that the message being sent is anything other than "hello world".

I KNOW that the example was not formatted that crappily. Why did you randomly add and/or remove tabs to make the code look like shit?

  byte msg[0];

An array that can hold nothing. How the f**k is that supposed to be useful?

     char recieved = acc.read(msg, sizeof(msg), 1);

You just shit on memory you don't own.

First point you are right i just need to send a string doesn't matter what string is.
second point i was wondering the same m not able to grasp the arduino code too...??
however when i send a single digit byte 1 or 0.it functions properly..??
sorry if i have not formatted properly.
"I KNOW that the example was not formatted that crapily. Why did you randomly add and/or remove tabs to make the code look like shit?"
also m sorry i dont understand what are you saying why are you getting angry,some context maybe..?? i just used replaced it with char .m not making the code look shit why are you getting so insecure m saying its my modified code.that code is fantastic and able to run led with 1 byte data but my question still stands what if i need to send more...i tried a byte array [128] size it still now works.it will be also helpfull if can explain the acc.read line.