在AndroidManifest.xml中添加权限,还要编写一个resource文件,具体参考http://developer.android.com/guide/topics/usb/host.html
解决方案 »
- HttpClient Header 传参数,请教,或者推荐一些类似的信息也行
- android 4.0.x 如何启动无法接收广播的程序
- 关于UI上控件按比例缩小
- 4.0 就是接收不了开机广播
- SystemProperties.set问题,很奇怪。。
- Android 蓝牙断开 资源释放问题
- eclipse离线安装adt报错
- eclipse emulator control unable to send command to emulator 求解
- eclipse新建工程中res 和layout为空
- 在嵌套的fragment里listview怎么没有值啊。。
- 在AppWidgetProvider派生类的方法中怎么操作成员变量
- android如何获取一个SD卡指定文件夹的图片Uri uri问题
内容如下:
<?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>
将android.hardware.usb.host.xml文件push到/system/etc/permissions目录下
然后关机,重新启动ok
mUsbManager.requestPermission(device, mPermissionIntent);
否则,在操作之前需要requestPermission获得权限
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lgx.MyTest"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk android:minSdkVersion="12" />
<uses-feature android:name="android.hardware.usb.host" android:required="true"/><!-- android:required="true" -->
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyTest"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> <intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter> <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" /> </activity>
</application></manifest>
现在有哪款android手机也支持啊
请回复啊
否则需要自己将android.hardware.usb.host这个feature加进去
上面是关键地方,余下的你自己研究吧