Monday, 13 February 2023

C# SerialPort with Java Android phone

what i'm trying to do:

  • Create an App for windows to connect android phone.
  • Send and receive data.
  • Windows (C#) is the host device --> android UsbAccessory.

C#:

As you can see, the COM5 is my Android phone

now i can select the COM5 (Android phone) and connect to it, using this code:

   serialPort1.PortName = this.devicesList.Text; // COM5
   serialPort1.Open();
   addToList("SerialPort is opened", Color.Green);

Java (Android Phone):

     UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
     UsbAccessory[] accessories = manager.getAccessoryList();

accessories is Always Null, i tried every code i find, but i could not do it.

what i'm doing wrong?

Thanks.



from C# SerialPort with Java Android phone

No comments:

Post a Comment