我实现了一个与NFC捕获器(CR95HF)通信的移动应用程序。它在API <23(在Android Marshmallow 6.0之前)的Android中完美运行,但在API> = 23的Android中不起作用。 我确定了问题,该问题出在BulkTransfer函数中,因为它返回-1(无响应)。我检查并尝试更改不同的参数,但没有任何变化: -端点方向正确 -存放时间:可以 -长度字段:确定 -超时参数:我设置了1000毫秒,尝试更改其他值,但没有效果 我也尝试过更改端点。
public void ioWrite(UsbDeviceConnection mConnection, UsbEndpoint mBulkOutEndpoint, byte[] buffer, int offset, int count)
{
if (mConnection == null)
{
throw new Exception("Connection was closed.");
}
int result = mConnection.BulkTransfer(mBulkOutEndpoint, buffer, offset, count, TIMEOUT);
if (result < 0)
{
throw new Exception("Bulk transfer failed.");
}
}
谢谢你。