ANDROID- 为什么 claimInterface 未安装 USB?

ANDROID- why claimInterface unmounted USB?

首先,这是事实。

  1. 应用程序正在使用 intent filter,只有特定的 USB 才能与应用程序通信。当检测到特定 USB 时,应用程序 将自动启动
  2. 其中一个按钮应用程序是browse file from internal and external storage. So, I expect the attached USB can be seen in the list
  3. 问题claimInterface:调试期间,执行usbDeviceConnection.claimInterface(usbInterface, forceClaim);后,应用程序将卸载连接的USB,导致2中所述的按钮无法列出连接的 USB。
  4. 如果我删除代码,应用程序无法与USB通信,但可以在浏览文件的列表中看到USB。
  5. 我用这个sample for intent filter and this sample浏览文件

所以,我的问题是,我可以在不卸载连接的 USB 的情况下执行 claimInterface 和 intent 过滤器,以便我可以浏览 USB 吗?

documentation for claimInterface 很清楚:

Claims exclusive access to a UsbInterface

这意味着没有其他应用程序或系统提供的 USB DocumentsProvider 可以再访问该 USB 设备:它们是互斥的。