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.

4

2 回答 2

4

我找到了答案。可以对 android 应用程序进行编程以检测是否支持 USB 附件模式。诀窍是使用 android PackageManager 来验证手机或平板电脑上是否存在 FEATURE_USB_ACCESSORY。下面给出了一个相关的代码片段:

        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();
        }

如问题中所述,此代码是在手机和平​​板电脑上测试的。手机提示“支持 USB 附件”,而平板电脑提示“不支持 USB 附件”。

于 2014-05-31T06:41:46.157 回答
0

看看Android AOAAOA 2.0。AOA 已经发布了两个版本,1.0 和 2.0。最新的是2.0。

Android 开放附件协议 2.0 增加了两个新功能:音频输出(从 Android 设备到附件)和支持作为一个或多个人机接口设备 (HID) 到 Android 设备的附件。

为了知道 AOA 的其他版本号,发送 USB 控制请求如下

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)

对于支持 AOA 2.0 的设备,控制请求将返回 2。

于 2014-03-26T06:37:55.717 回答