如何检测Honeycomb中的MTP/PTP设备?

发布于 2024-12-02 08:20:46 字数 251 浏览 4 评论 0原文

我想在插入 Android 设备时检测 MTP/PTP 设备。我知道有一种使用 Intent 的方法: android.hardware.usb.action.USB_DEVICE_ATTACHED 然后使用 ,但不起作用。系统不会将此意图发送到已注册的应用程序。

因此,有人知道该怎么做吗?

I want to detect the MTP/PTP device when it plugs in the android device. I know there is one method using Intent: android.hardware.usb.action.USB_DEVICE_ATTACHED and then defining meta-data which using resource like <usb-device class="6" subclass="1" protocol="1">, but it doesn't work. The system doesn't send this intent to the registered application.

Thus, does anyone know how to do it?

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

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

发布评论

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

评论(2

无声静候 2024-12-09 08:20:46

您是否通过添加 进入
AndroidManifest.xml

<uses-feature android:name="android.hardware.usb.host" /> 

Have you set the machine to act as USB host by adding into
AndroidManifest.xml:

<uses-feature android:name="android.hardware.usb.host" /> 
雨落□心尘 2024-12-09 08:20:46

您能具体说明您用于测试的设备是什么吗?
您的设备很可能在 USB 设备描述符和/或接口描述符的类、子类和协议中没有 PTP/MTP 特定值。
请参阅:http://events.linuxfoundation.org/站点/事件/文件/幻灯片/Media%20Transfer%20Protocol.pdf
某些设备将自己宣传为大容量存储设备或特定于供应商的设备。
如果是这种情况,唯一的方法是尝试匹配您想要支持的设备的供应商 ID 和产品 ID。
这里还有一个 MTP 设备列表及其供应商 ID 和产品 ID: http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h

希望这有帮助。

could you please specify what is the device you are using for testing?
It is very likely that your device has no PTP/MTP specific values in class, subclass and protocol for the USB device descriptor and/or interface descriptor.
See this: http://events.linuxfoundation.org/sites/events/files/slides/Media%20Transfer%20Protocol.pdf
Some devices advertise themselves as Mass Storage devices or Vendor Specific.
If that is the case the only way is to try matching the vendor id and product id of the devices you would like to support.
Here is also a list of MTP devices with their vendor id and product id: http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h.

Hope this helps.

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