2

I am developing an application to interface an accessory using Android Open Accessory (AOA) protocol.

I test the application using either a handset(Android 4.2.2) or a tablet (Android 4.1). Both these devices have USB Micro-B receptacle, whereas, accessory has USB A type receptacle. I use Micro-B plug to USB-A plug cable to connect any one of the earlier mentioned Android device with Accessory.

The application is expected to popup as soon as accessory is connected to handset or Tablet.

It is working as expected on handset but not on the tablet. After putting good amount of time on debugging this issue, it is occurring to me that the tablet may not be supporting AOA Protocol. (JFYI: The table supports OTG mode).

Therefore my questions are:

1) Has anyone came across any app which can inform whether device supports AOA or not? 2) Does anyone know programmatic way to detect support for AOA on android device?

Thanks in advance for forthcoming help from community members.

P.S. I have already read answer for similar issue mentioned at - 1) How to tell if an Android device has Open Accessory Mode 2) Does the Acer Iconia Tab A500 support Accessory mode? 3) What Android Tablet Currently Supports Accessory Mode for ADK Development 4) Which android devices support the ADK / open accessory - without any outcome.

Community
  • 1
  • 1
SunGa
  • 231
  • 3
  • 10

2 Answers2

5

I found the answer. The android app can be programmed to detect if the USB accessory mode is supported or not. The trick is to use android PackageManager to verify FEATURE_USB_ACCESSORY is present or not on the phone or tablet. Given below is a relevant code snippet:

        PackageManager pm;
        pm = getActivity().getPackageManager();
        boolean isUSBAccessory = pm.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY);

        if(!isUSBAccessory){
            Toast.makeText(getActivity(), "USB Accessory not supported", Toast.LENGTH_SHORT).show();
        }else {
            Toast.makeText(getActivity(), "USB Accessory supported", Toast.LENGTH_SHORT).show();
        }

This code is test on a phone and a tablet, as mentioned in the question. The phone toasts the message "USB Accessory supported", where as, the tablet toasts "USB Accessory not supported".

SunGa
  • 231
  • 3
  • 10
0

Have a look at Android AOA & AOA 2.0. AOA has released two versions, 1.0 and 2.0. The latest being 2.0.

The Android Open Accessory Protocol 2.0 adds two new features: audio output (from the Android device to the accessory) and support for the accessory acting as one or more Human Interface Devices (HID) to the Android device.

In order to know ther version number of AOA, send a USB control request as follows

requestType:    USB_DIR_IN | USB_TYPE_VENDOR
request:        51
value:          0
index:          0
data:           protocol version number (16 bits little endian sent from the
                device to the accessory)

For AOA 2.0 supported devices, the control request will return 2.

  • Thanks but My question is different - My need is that the android application itself shall detect whether the AOA is supported on the phone or tablet. I think you answer is fit for the accessory connected to handset or Tablet. – SunGa Mar 26 '14 at 17:00