原来的代码如下 int c; int matchIndex = 0; while (-1 != (c = this.inputStream.read())) { list.add((byte) c); if (c == (0xff & data[matchIndex])) { matchIndex++; } else { matchIndex = 0; } if (matchIndex == data.length) { break; } } 当接收数据的正文 含有包尾数据的头部时会触发不了OnResponse 应更改如下 int c; int matchIndex = 0; while (-1 != (c = this.inputStream.read())) { list.add((byte) c); if (c == (0xff & data[matchIndex])) { matchIndex++; } else { if(c==(0xff & data[0])) matchIndex=1; else matchIndex = 0; } if (matchIndex == data.length) { break; } }
Activity