简体   繁体   English

通过USB在Android设备和PC(Mac或Windows)之间进行双向数据传输

[英]Bi-directional data transfer through USB between an Android device and a PC (Mac or Windows)

I am new to Android programming. 我是Android编程的新手。 I need to transfer data bi-directionally over USB between an Android tablet and a PC (Mac or Windows). 我需要在Android平板电脑和PC(Mac或Windows)之间通过USB双向传输数据。 The Android tablet will have Android 4.0 or newer. Android平板电脑将配备Android 4.0或更高版本。 Mac will have OS X Lion or newer and Windows will have Windows XP or newer. Mac将具有OS X Lion或更高版本,而Windows将具有Windows XP或更高版本。

After reading about Android's support for USB connectivity here: http://developer.android.com/guide/topics/connectivity/usb/index.html 在这里了解了Android对USB连接的支持后: http//developer.android.com/guide/topics/connectivity/usb/index.html

I'm thinking if I get the Android tablet run in USB accessory mode and make the PC the host, bi-directional data transfer over USB can work. 我在想,如果我让Android平板电脑在USB附件模式下运行并使PC成为主机,则可以通过USB进行双向数据传输。 Is that thinking correct or I'm way off here? 那是正确的想法还是我离开这里?

Thanks. 谢谢。

Your best bet is probably ADB push/pull of files (assuming that's what you want to transfer). 最好的选择可能是ADB推/拉文件(假设这就是您要传输的文件)。 Your Windows-side application would have adb and AdbWinApi.dll as assets, and the OSX version would have the Mac OS ADB binary... There are obvious downsides such as having to have Developer options enabled on the device, and possible interference from a pre-existing copy of the Android SDK on the host machine (typically very unlikely, but possible!) 您的Windows端应用程序将adb和AdbWinApi.dll作为资产,而OSX版本将具有Mac OS ADB二进制文件...存在明显的不利影响,例如必须在设备上启用Developer选项,以及可能受到来自Windows的干扰。主机上预先存在的Android SDK副本(通常不太可能,但有可能!)

More advanced: Depending on the environment, you may even want to look into building your own version of ADB from source with unnecessary features omitted. 更高级:根据环境,您甚至可能希望从源代码构建自己的ADB版本,而忽略不必要的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM