在android开发USB功能时,少部分android的手机不支持USB的功能,使用如下代码测试:
boolean ret=getPackageManager().hasSystemFeature("android.hardware.usb.host");
调用后ret返回false,表示该手机不支持USB功能。
解决办法如下:
1.使用root工具root手机(推荐使用root大师)
2.在命令行运行
adb shell; //打开手机的shell执行
chmod 777 /system/etc/permissions/ //修改/system/etc/permissions/ 目录为可写
如果在执行chmod 777 /system/etc/permissions/ 命令时提示Read-only file system,需要先执行如下命令:
mount -o remount rw /system
3.在/system/etc/permissions 下,添加 android.hardware.usb.host.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>
修改/system/etc/permissions目录下的handheld_core_hardware.xml文件,在<permissions>节点中加入如下代码:
<feature name="android.hardware.usb.host" />
4.重启手机
相关推荐
android下USB Host开发的一些注意事项和开发步骤
用于检测Android平板是否支持USB HOST API
可以接收单片机发送的usb hid信息,并显示在android手机上
Usb Host ADK是指不采用USB驱动,直接用java与设备编程的 这样让Android 可以无需修改内核和驱动情况下方便与各种USB外设通讯
Check检测是否支持USB HOST功能的小应用方便查看本机支持情况。包括三项检查:是否支持android.hardware.usb.host.xml、是否支持handheld_core_hardware.xml和是否支持tablet_core_hardware.xml。 本人的平板只有第...
3.1版本之后支持的usb host API。可以通过usb接口让安卓设备作为主设备来接收来自usb的数据,比如平板上插个单片机,就可以接收单片机的数据了。该程序封装了多个包,实现了该功能。
做usb accessory通信时,myUsbManager.getAccessoryList();return null,说是少文件。解决办法是先root手机,然后把这两个文件推送到手机的/system/etc/permissions目录下。
此demo实现两个android设备通过usb线进行相互通信,用于host和devices之间通信
安装此apk,后运行,可对android手机进行host映射 前提是手机己经root,并且有写入权限
how to enable android usb host api
本人最近在Android的PAD上开发USB Host数据传输。(见附件) 对CH340,已经能够正常读写;但对CH341只是可以正常写出,读入总是有问题:只有当USB缓存满32字节时,才可以读入数据(数据是对的)。 不知道有无同行在CH...
本人最近在Android的PAD上开发USB Host数据传输,USB驱动芯片是PL2303。(见附件)已经能够正常读写。欢迎试用。
Android USB host简介,中文文档
启用android usb host功能的xml文件。 需要将这个文件加到设备的/system/etc/permissions/目录下,才能开启android设备的usb host权限。
Atmel AVR4960 USB Host Android Accessory
此demo为android usb host开发 pL2303demo 其他型号修改id即可通用,开发usb host 穿戴设备
NULL 博文链接:https://dengzhangtao.iteye.com/blog/1860520
开启android系统的USB Host模式实现通讯
The Android architecture does not allow to start communication from the Android to the host through the USB cable.The opposite is possible, using the Google "Android Debug Bridge" (ADB in short)....
android_USB_Host应用函数列表