虽然这样的答案可以深入了解所需的电缆和所需的引脚连接,并且这个答案提供了有关驱动程序和不良电缆的先决条件的信息,但都没有回答我上面提出的核心问题。
Android Docs提供了有关如何在检测到设备后访问设备的信息,但对于我实际连接设备的问题没有任何帮助。
答案来自这篇文章,其中指出:
We have identified 3 requirements for an Android device to support USB Host Mode and be able to communicate
with [The USB Device]:
[1] The Android device must be running version 4.1 (Jelly Bean) of the OS, or higher.
[2] The output power on the Android device's USB port should be 5V.
[3] The configuration file android.hardware.usb.host.xml must exist on the Android device in the folder
/system/etc/permissions. The presence of this configuration file is what enables USB
Host Mode on your Android device.
第三点是我想提请注意的,因为有问题的 xml 文件是这个:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This is the standard feature indicating that the device can communicate
with USB devices as the USB host. -->
<permissions>
<feature name="android.hardware.usb.host" />
</permissions>
如您所见,这是一个简单的 XML 文件。但是正如这个答案所概述的,它需要在根级别完成才能访问它。
这里的结果是操作系统需要在内核级别将此文件设置到正确的目录中,或者设备需要在事后植根并放入。
这两种解决方案之一将解决此问题。