如何设置USB连接模式?

发布于 2024-10-12 20:56:51 字数 183 浏览 3 评论 0原文

我正在编写一个应用程序,该应用程序应该将数据转储到 SD 卡上,然后在 PC 上编写另一个应用程序,当设备连接到 PC 时(在光盘驱动器模式下),该应用程序应该读取数据。 在我的 HTC Legend 上,有一个对话框可供选择:仅充电、HTC Sync、磁盘驱动器...

是否可以设置设备连接到电脑的模式 或者至少意图要求用户切换模式?

I'm writing an application which is supposed to dump data on the SD card and then another application on a pc which should read the data when the device is connected to the pc (in disc drive mode).
On my HTC Legend there is a dialog to choose between: Charge only, HTC Sync, Disk drive..

Is there a possibility to set the mode with which the device is connecting to the pc
or at least an intent to ask the user to switch the mode?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

冬天的雪花 2024-10-19 20:56:51

我还没有找到以编程方式设置模式的方法,但我相信您可以通过调用系统从通知区域调用的相同活动来以编程方式调出设置菜单。不幸的是,这似乎是特定于制造商的:在我的手机上,它是 com.htc.android.psclient.SwitchUsbSettings 。

I haven't found a way of setting the mode programmatically, but I believe you can bring up the settings menu programmatically by invoking the same activity that the system invokes from the notification area. Unfortunately this appears to be manufacturer-specific: on my phone it is com.htc.android.psclient.SwitchUsbSettings.

乙白 2024-10-19 20:56:51

在 HTC 设备上,在“管理应用程序”(ICS - 可能也适用于 Gingerbread;不记得了)中打开 ConnectToPC 服务(未插入 USB 时),然后点击“清除数据”。然后,再次插回 USB,您应该可以选择“不再询问”。选择您想要的模式,选中该框并接受。

On HTC devices, open the ConnectToPC service (whilst USB is not plugged in) in Manage Apps (ICS - probably applies to Gingerbread too; don't remember), and hit Clear Data. Then, plug the USB back again, and you should have the option to "Don't ask again" available. Select your desired mode, check the box, and accept.

风和你 2024-10-19 20:56:51

当您在 Android 应用程序中请求 USB 同步时,CompanionLink 会执行此操作:它将数据刷新到 SD,然后将 SD 作为 USB 上的存储(“磁盘驱动器”)导出,然后等待用户在同步时手动向 Android 应用程序发出信号。 PC 使用完 SD,然后再次撤消 SD 导出到 USB。尽管 CompanionLink 应用程序使用起来非常令人沮丧,但至少它的这一部分(很大程度上)是可靠的。

不幸的是,我不知道技术细节,可能需要在这几个月里自己弄清楚它们。如果你无法从 android 文档中获得任何牵引力,也许你可以研究 CompanionLink 在 android 上做了什么来实现这一点。我上面描述的顺序是当它被配置为通过 USB 与(基于 PC 的)Palm 桌面同步时的顺序。

顺便说一句,这个高度复杂的过程的原因似乎是直接访问SD卡的FS,并且至少目前使用的卡FAT FS只能支持单个客户端:手机本身或USB。在我看来,如果可以对 SD 进行并发共享访问,那将非常有帮助,但这可能需要对 Android 进行深入的更改。

CompanionLink does this when you request a USB sync in their android app: it flushes data to SD, then exports the SD as storage (a "disk drive") on the USB, then waits for the user to manually signal the android app when the PC is finished using the SD, and then undoes the SD export to USB again. Though the CompanionLink app can be very frustrating to use, at least this part of it is (largely) reliable.

Unfortunately I don't know the technical details, may well need to figure them out myself one of these months. If you can't get any traction with android docs, perhaps you could study what CompanionLink does on android to implement this. The sequence I describe above is when it is configured to sync over USB against a (PC-based) Palm Desktop.

As an aside, it appears that the reason for this highly-convoluted process is that the SD card's FS is accessed directly and at least the presently-used card FAT FS can only support a single client: the phone itself or USB. imo it would be extremely helpful if concurrent shared access to the SD were possible, but this would likely require deep android changes.

锦欢 2024-10-19 20:56:51

对于任何使用 HTC One M8 遇到此问题的人来说,这有点离谱,但需要跳出框框思考。 USB 连接导致设备充电,仅此而已。

解决方案是结合不同的 USB 电缆,卸载名为 Battery Doctor 的应用程序(它显然喜欢管理电池周围的所有内容),以及 USB 网络设置 - 打开智能网络共享...看似无关...但这种组合连接 MobileGo for Android 来管理和备份文件、联系人和设置。

希望这对某人有帮助。

For anyone having this issue with an HTC One M8, this is a bit off the wall, but makes the point to think outside the box. A USB connection resulted in the device charging, that was it.

The solution was the combination of a different USB cable, uninstalling an application called Battery Doctor (which apparently likes to manage everything around your battery), AND USB Network Setting - turn ON Smart Network Sharing...Seemingly unrelated...but this combination got my connected with MobileGo for Android to manage and back up files,contacts and settings.

Hope this helps someone.

罗罗贝儿 2024-10-19 20:56:51

是的。在 Android 中,有一种方法可以在设备与 PC 连接时更改设备 USB 模式的行为。
我使用了 Motorola Milestone[运行 2.1],并且能够在以下模式之间切换:
PC Suite[摩托罗拉开发]、MemoryCardAccess 和 Charge 单独使用。
如果您需要访问手机内存,我认为您应该在设备中打开“USB 调试模式”。虽然我不确定,但我觉得它可能很方便!

Yes .In Android there is a way to change the behaviour of the devices`s USB mode when the device is connected with the PC.
I used a Motorola Milestone[running 2.1] and i was able to switch between the following modes :
PC Suite[developed by Motorola],MemoryCardAccess and Charge alone.
If you need to access phone memory I think you should turn ON "USB Debugging Mode " in your device.Am not sure about it though,I feel it may be handy !!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文