Can we transfer data via USB Host API to a PC via a USB cable?

Please help me with this,

In my project, I need to transfer data from an Android device (3.0 and above) to a PC via a USB cable, regardless of the USB debugging mode (the USB debugging option should not be selected).

So, is it possible to transfer data to a PC using the USB host API?

Thanks in advance.

+7
source share
2 answers

You can, just as the wireframe works.
The only difference between the USB host function is that when the android is in host mode, it supplies power.
It depends on the device, not the lvl API. But you do not need the host function, because the computer is the host.
You want to be in extra mode.
For more information, check: Accessories Mode

0
source

You need a USB data cable (also called a USB data cable), which

Support API or SDK, then use the following code:

void CU2uDlg::OnOK() { BYTE buf[65530]; LPU2URET pU2uRet; BOOL bRet; int ret; CString msgstr; ret = u2u_open(); if (ret == -1){ AfxMessageBox("Open U2U device Success."); }else{ msgstr.Format("Open U2U device fail,return:%d", ret); AfxMessageBox(msgstr); return; } //send data bRet = u2u_SendData(buf, 65530, ret); if(!bRet) { msgstr.Format("Send data error,return:%d", ret); AfxMessageBox(msgstr); return; } //receive data while (1){ bRet = u2u_RecvData(recvData, dataLen, ret); if( !bRet ) { msgstr.Format("Receive data error,return:%d", ret); AfxMessageBox(msgstr); u2u_close(); return; }else{ break; } } u2u_close(); } 

Cm:

Reference1 , Reference2

0
source

All Articles