线
strPuffer = new String(buffer, 0, bytes, Charset.forName("UTF-8"));
导致很多 GC_CONCURRENT ......
while (true) {
try {
// Read from the InputStream
bytes = mmInStream.read(buffer);
strPuffer = new String(buffer, 0, bytes, Charset.forName("UTF-8"));
curMsg.append(strPuffer);
int endIdx = curMsg.indexOf(end);
if (endIdx != -1) {
fullMessage = curMsg.substring(0, endIdx + end.length()-1);
curMsg.delete(0, endIdx + end.length());
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothChat.MESSAGE_READ, bytes, -1, fullMessage)
.sendToTarget();}
} catch (IOException e) {
//
connectionLost();
break;
}
}
我该如何防止呢?