解决方案 »
- android显示图片内存溢出问题
- radio切换为前台播放时却丢失了音频焦点问题
- android 自定义ListView布局中动态加入几个TextView控件, 如何获得每个TextView来单独改变某一个TextView的文字颜色啊 。
- 多表查询
- emulator命令启动模拟器失败
- 请教:XT800播放在线音乐问题
- 自己开发的android 软件怎么销售
- 问问Android多线程问题。
- android bluetooth
- 引入library project打包混淆错误
- android AsyncTask, Wrote stack traces to '/data/anr/traces.txt'
- 大家都用什么APP统计分析工具?
设备都不支持你用的那些api,设备都无法识别,你乱导入库也没用呀。
是的Google APIs 14的
是的Google APIs 14的这里有相关的说明和简单操作,你看看先。
http://www.2cto.com/kf/201211/171678.html
谢谢,这些文章我之前也看过,现在我直接列举附件设备都获取不到
是报异常还是直接获得对象为空?为空应该是权限的问题,你试试以下方式:
To enable USB host API support you should add a file named
android.hardware.usb.host.xmland containing the following lines:<permissions>
<feature name="android.hardware.usb.host"/>
</permissions>into folder/system/etc/permissionsin that folder find file namedhandheld_core_hardware.xml or tablet_core_hardware.xml and add<feature name="android.hardware.usb.host">
谢谢,这些文章我之前也看过,现在我直接列举附件设备都获取不到
是报异常还是直接获得对象为空?为空应该是权限的问题,你试试以下方式:
To enable USB host API support you should add a file named
android.hardware.usb.host.xmland containing the following lines:<permissions>
<feature name="android.hardware.usb.host"/>
</permissions>into folder/system/etc/permissionsin that folder find file namedhandheld_core_hardware.xml or tablet_core_hardware.xml and add<feature name="android.hardware.usb.host">
host我这边是好的,可以获取u盘信息,就是accessory不行
谢谢,这些文章我之前也看过,现在我直接列举附件设备都获取不到
是报异常还是直接获得对象为空?为空应该是权限的问题,你试试以下方式:
To enable USB host API support you should add a file named
android.hardware.usb.host.xmland containing the following lines:<permissions>
<feature name="android.hardware.usb.host"/>
</permissions>into folder/system/etc/permissionsin that folder find file namedhandheld_core_hardware.xml or tablet_core_hardware.xml and add<feature name="android.hardware.usb.host">
host我这边是好的,可以获取u盘信息,就是accessory不行
方便贴代码看看不?我也是黔驴技穷了。
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature android:name="android.hardware.usb.accessory" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<uses-permission android:name="android.hardware.usb.accessory" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.android.future.usb.accessory" />
<activity android:name="com.example.test.usb.MyUsbAccessary" >
<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_ACCESSORY_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="@xml/accessory_filter" />
</activity>
</application></manifest>public class MyUsbAccessary extends Activity {
private static final String ACTION_USB_PERMISSION = "com.UARTLoopback.USB_PERMISSION";
public static String ManufacturerString = "mManufacturer=FTDI";
public static String ModelString1 = "mModel=FTDIUARTDemo";
public static String ModelString2 = "mModel=Android Accessory FT312D";
public static String VersionString = "mVersion=1.0"; @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_myusb); final UsbManager manager = UsbManager.getInstance(MyUsbAccessary.this); new Handler().postDelayed(new Runnable() { @Override
public void run() {
UsbAccessory[] accessoryList = manager.getAccessoryList();
if (accessoryList == null) {
Toast.makeText(MyUsbAccessary.this, "null", 3000).show();
} else {
Toast.makeText(MyUsbAccessary.this, accessoryList[0].getDescription(), 3000).show();
}
}, 3000); }}