question

EmilAlipiev-5934 avatar image
0 Votes"
EmilAlipiev-5934 asked RobCaplan edited

Xamarin.Android/Forms app communicating with a PC over the usb

Is it possible to send commands over the usb connection between Xamarin.Android app and Pc app?
So basically I would like send some text over the port and PC app is listening the port and reads it and display it? Pc app is not matter, Uwp, Wpf, Xamarin.forms etc. what matters is how to send the message from Android over the usb.
using Bluetooth it is already possible and I have achieved it but I dont know how to achieve this over the usb.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered JarvanZhang-MSFT commented

Hello,​

Welcome to our Microsoft Q&A platform!

To make the Xamarin.Android/Forms app communicate with a PC, it's a good choice to use TCP/IP client. You could refer to the links from this comment:
https://forums.xamarin.com/discussion/comment/393629/#Comment_393629

If you want to perform the communication via usb, you may need to consume a tool or library.
Check the links:
https://stackoverflow.com/questions/49015125/communicating-with-a-website-via-usb-connection-to-a-xamarin-android-app
https://forums.xamarin.com/discussion/127902/xamarin-forms-android-app-connect-communicate-via-usb-to-pc

Best Regards,

Jarvan Zhang



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

xamarin forum seems to be totally closed and cannot reach any information there any longer.
Basic question, how to send a message over the usb connection from Android device to Windows 10 PC.
There is host mode and accessory mode, in this case, host is Android phone i think?

0 Votes 0 ·

1.The forms has officially moved to the Microsoft Q&A now. However, the threads could still be accessed.

2.You could establish a connection and deliver messages through a socket.
https://stackoverflow.com/questions/21748790/how-to-send-a-message-from-android-to-windows-using-usb

3.Related links you could refer to:
https://stackoverflow.com/a/51438230/11083277
https://developer.android.com/guide/topics/connectivity/usb/

0 Votes 0 ·