Sending a file to a computer system using USB

I have a requirement in which I need to transfer a file to a computer system, consider a Windows PC.

What I want to do is I have one screen with specific details, I write these values ​​in one text file, now, if the user clicks the button, then this file must be copied to the computer in a specific place using USB.

I tried to find out about it, but got nothing. I also link to the link

http://developer.android.com/guide/topics/connectivity/usb/host.html

Is it possible in Android, how can I communicate with the Windows system?

Hello

UPDATE:

I can use sopy files for computer using adb

 ./adb -s emulator-5554 pull /sdcard/juned.jpg /root/juned/android_usb/ 

but can i do the same from an android app?

+1
source share
2 answers

I think your question is not very specific in order to get an answer. But to explain a bit, consider the following:

  • you need to turn your Android device into USB host mode so that it lists the connected USB devices.
  • Establish a connection with the receiving device. It will probably be a storage or disk with a known endpoint configuration.
  • when creating, use a function of the type bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int offset, int length, int timeout), , which is also documented in the link you specified. Keep in mind to select the correct endpoint (direction to your storage / drive).

This is just a sketch to get you started. Clearly, there is still much to be done.

0
source

USB is probably not very suitable for what you want to do.

USB is asymmetric, meaning a USB connection has a host on one end and a peripheral device on the other end. (For example, when you connect a USB drive to a PC, the PC is the host, and the stick is peripheral.) The host initiates and controls the data transfer.

An Android phone usually acts as a peripheral device. Starting with Android 3.1, the phone can also act as a USB host, although not all phones support this.

In order to accomplish what you mean, the PC will need to run a piece of software that changes it from host mode to peripheral mode and provides some kind of storage that the Android device could record.

Bluetooth may be the best option for you. You can simply initiate the file transfer via Bluetooth immediately after changing the file. Inexpensive Bluetooth USB dongles are available for PCs without Bluetooth support. You may need some software on your PC if you want to automatically accept the request to transfer files to your PC.

0
source

All Articles