How can I get the ADK DemoKit example working on a Google I/O Galaxy Tab 10.1?

不打扰是莪最后的温柔 提交于 2019-11-29 02:33:50

My apologies, accessory mode currently doesn't work with the Samsung Galaxy Tab 10.1. Samsung is aware of the issue and is working on resolving it. When the device does support accessory mode you should be able to use the com.android.future.usb.* APIs which will make it easier for you to write an app that works both with Android 3.1 and 2.3.4.

I just got the new TouchWiz update and now the Arduino reads this back to the serial port:

Device addressed... Requesting device descriptor.found possible device. swithcing to serial mode
device supports protcol 1

Device addressed... Requesting device descriptor.found android acessory device
config desc
interface desc
inEp: 1
outEp: 2

This is looking much better. The Galaxy Tab asks to run DemoKit, I hit OK, and it force quits. This better than it was previously.

I will update if I get it working fully.

Are you sure you are using the right build target? Instead of regular "Android 2.3.3" (level 10) or "Android 3.1" (level 12), you should use "Google APIs" targets. If you run "Android SDK and AVD Manager", you can find them under Available Packages > Third party add-ons > Google Inc > "Google APIs by Google Inc., Android API 10" (or 12).

Moritz

My Galaxy Tab 10.1 on Android 3.1 didn't have the accessories API as a backport as well. So I got the following exception as well:

java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager

One way to bringing it to work on the Tab 10.1 with Android 3.1 is to use the regular accessory API. Not the backported version. You can set your DemoKit projects target SDK to the regular API level 12 (Android 3.1).

In addition you have to change the code passages in the DemoKitActivity to get the UsbManager and the UsbAccesory to:

UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
UsbAccessory accessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);

imports change to:

import android.hardware.usb.UsbAccessory;
import android.hardware.usb.UsbManager;

The Android manifest can still contain the following entry but it is not required anymore:

<uses-library android:name="com.android.future.usb.accessory" />
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!