I am testing my app in Samsung Galaxy S2 with Android 2.3.4
I am following
http://developer.android.com/guide/topics/usb/accessory.html
instructions.
When ever I try to run it, usbManager.getAcccessoryList(); giving null.
Even I tried by connecting OTG cabel and pendrive to it.
My manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature android:name="android.hardware.usb.accessory" />
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<uses-library android:name="com.android.future.usb.accessory" />
<activity
android:name=".SplashScreen"
android:clearTaskOnLaunch="true"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Advanced"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Edit"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Add"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="Main"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="@xml/accessory_filter" />
</activity>
</application>
</manifest>
A cite from http://developer.android.com/guide/topics/usb/accessory.html: "Set the minimum SDK of the application to API Level 10 if you are using the add-on library or 12 if you are using the android.hardware.usb package." You are using the android.hardware.usb package. So, you have to put the version to 12.
An error is found :-)
And don't forget to really change SDK version to 12, not only declare it!
Use com.android.future.usb package instead, according to docs.