androidfileusbhostaccessory

Host Mode or Accessory Mode


I have an android device that serves me as an interface between a machine and the operator, the communication is done via Bluetooth. the power to charge the battery is provided by the machine.

I have built a cable that makes possible to charge the android device battery and also to connect a pen-drive. More or less like the picture...

Here comes my doubt, as VCC and GND is provided by the machine and the android device must create and manipulate a file into the pen-drive, should i configure the android device as host or accessory??

Thanks in advance.

cable schema


Solution

  • Android (or for that matter anything) can only directly operate a USB Mass storage device (aka a "pen drive") while operating in the host role, as a Mass Storage Device is a "device" and can only communicate with a "host". So that literally answers your question.

    Normally, a device operating in the host role doesn't accept power through USB connector, but there have been various efforts to get around this. If your device can or can't is a separate question.

    It's also worth noting that legacy versions of stock Android wouldn't directly interact with a USB Mass storage device - one was required to implement the mass storage interface and filesystem code within an app or use a customized version of Android which would. This may have since been changed.