本文介绍了如何确定UsbRequest.queue(..)方法接收的字节长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安卓3.1的烦恼与UsbRequest类。

I have troubles with UsbRequest class in Android 3.1.

这是我的code:

ByteBuffer buffer = ByteBuffer.allocate(4096);
buffer.order(ByteOrder.LITTLE_ENDIAN);
UsbRequest request = new UsbRequest();
request.initialize(mConnection, mEndpointIn);
request.queue(buffer, 4096);

if (mConnection.requestWait() == request) {
   byte[] data = buffer.array();
}

数组的大小数据是4096,但确实接收的字节长度更小。

The size of array data is 4096, but the length of really received bytes is much more smaller.

我怎么能确定真正接收的字节大小?

How can i determine the size of really received bytes?

感谢。

推荐答案

这是Android的一个错误。在受灾的版本,有没有解决方法,因为实现根本不通过长了起来。

This was a bug in Android. On afflicted versions, there's no workaround, because the implementation simply doesn't pass the length up.

这是固定在JB-MR1(API级别17起)。

It was fixed in JB-MR1 (API level 17 onwards).

这篇关于如何确定UsbRequest.queue(..)方法接收的字节长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 19:16