2

I am working on one android app where I am trying to establish a communication between android device and machine which runs on windows OS. I want to transfer some bytes from android device to that machine using USB.

I believe that machine which runs on windows OS always act as host. correct ?

I see android has two API's

Can anyone suggest me which API will work for me ?

N Sharma
  • 33,489
  • 95
  • 256
  • 444

1 Answers1

2

I believe that machine which runs on windows OS always act as host. correct ?

Yes. Windows OS will act as USB host.

Can anyone suggest me which API will work for me ?

Your android device will act as accessory. So follow the Accessory APIs.

Shaibal
  • 907
  • 8
  • 18
  • If you see this https://developer.android.com/guide/topics/connectivity/usb/accessory.html#working-a "When users connect USB accessories to an Android-powered device," - This API is for when you connect USB accessories not host ? – N Sharma Jul 09 '17 at 05:33
  • Yes. This link says about your Android device as host and you can connect other accessories to it. But as per your main question, your Android device is accessory and the PC is host. I have never seen any PC which can act as device mode too. – Shaibal Jul 09 '17 at 14:16
  • so links says android device as host then I want to be as accessory, then how accessory would fit for me ? – N Sharma Jul 09 '17 at 16:51
  • You are getting confused. Android device can act as host as well as accessory. When you want it to act as accessory, you need to use accessory APIs to reply to the host requests like Control transfers, data transfers. From the accessory link in your question, "USB accessory mode allows users to connect USB host hardware specifically designed for Android-powered devices". This line is clear and it says that you need to use these APIs if you want to connect a host hardware to Android device which will initiate all the transfers. – Shaibal Jul 09 '17 at 17:02
  • I see, it was very clear, this line made me confused "When users connect USB accessories to an Android-powered device," anyways thank you for your help :) – N Sharma Jul 10 '17 at 04:41