English 中文(简体)
Android 牙齿投入/投入: 收到1008份
原标题:Android Bluetooth Input/Outputstream: Sent ~1400 bytes, received 1008

我试图在两部4.0.1电话之间发送数据,在我发送数据时,我没有在另一边接收全部数据。

我的法典:

byte[] buffer = new byte[4096];
int bytes;

bytes = inputStream.read(buffer);
// bytes = 1008
// buffer[1008..4095] = 0 
// =================== other side =============================
byte[] message = Tools.concatByteArray(response, authorizationMessage);

// Debug tells me that the array has 1400 bytes
outputStream.write(message);
outputStream.flush();

de中的信息是:

[102, -32, 27, 23, 31, 111, -43, 124, 105, -122, 89, 13, 80, 62, 107, -21, 44, -93, -24, 100, -28, 18, -10, -55, 8, -7, 95, -82, -127, -125, -13, -14, 82, 93, -112, 33, 5, -43, 82, -89, -60, 111, 61, 5, 65, 1, -105, -65, -77, -119, 126, -118, -67, 32, -115, 106, -10, 75, 44, 101, 60, -110, -71, -27, 44, -111, 83, 83, 99, -25, -71, 12, -101, -35, -79, -115, 99, 107, 21, 118, -52, -107, -51, -122, 106, 12, 43, 23, 111, -60, -79, -20, 57, -28, 99, -106, -87, 74, -18, 71, 44, -26, -6, 80, -124, 34, -69, 27, 46, -15, -97, -71, 84, 30, -121, -36, 65, -46, 66, -34, 69, -127, -16, 100, 114, 38, -110, -24, -34, 82, 69, -75, 108, 42, 83, 103, -14, -54, 10, 85, 107, -1, 42, 41, 106, 4, 65, 122, -101, -45, 19, 32, -110, 61, 53, 73, -97, -119, -63, 96, 55, -103, -59, -84, -35, -64, 47, -58, -38, 8, 9, 3, 82, -109, -78, 124, 69, -2, -74, -55, 72, -26, 33, -110, 92, -48, 87, 81, 39, 95, -45, 121, -82, -75, -79, -104, 93, 37, -118, 108, 20, -49, -96, 74, -120, -89, 110, -36, 115, 69, 98, 99, -21, 48, 112, -42, -124, 7, 18, 32, -126, -47, 87, -33, -5, -83, -2, 61, 85, -31, -18, 109, -75, 75, -16, 57, 67, 90, 98, 54, -27, -79, 111, -119, 67, 106, -3, 43, 56, -56, -115, -118, 15, -80, -83, -83, 101, 116, 46, -89, 113, -38, 33, -49, -114, -90, -20, 59, -50, 27, -98, 41, 116, -73, 48, 92, -104, -5, 74, -91, 75, 49, 35, 9, 65, -47, 35, 17, 27, -112, -64, -80, -104, 0, -109, 55, 89, 11, 42, -22, 86, -125, 127, 1, -27, -64, 21, -119, 15, 79, 27, -2, -18, 36, 77, 47, -32, 81, -117, -107, 112, 52, 125, -116, -83, -34, -15, 31, -37, 19, -65, 28, -93, -102, 12, 83, 108, 88, -5, 121, -107, -71, -3, 65, 18, -99, -92, 103, -9, 57, 90, 93, 29, 13, -14, 122, 126, -32, 54, 90, -126, 10, -123, -94, 46, -90, -11, -93, -75, 23, -18, 36, 51, 8, 115, -122, -44, -59, -99, -127, 33, -107, -116, 11, -94, -94, 92, -51, 94, -15, -72, 78, 82, 10, -14, -81, -121, -57, -55, 4, -64, 89, -69, -26, 24, 10, -27, -44, 80, 3, 11, -7, 127, 109, 3, -20, -52, 92, 31, -80, -13, -127, -73, -61, -11, -1, 110, 52, 100, -72, -73, 29, -98, -55, -39, 14, 48, 71, 79, -60, -29, -61, 97, -48, -59, -61, -117, 89, -73, 95, -4, -8, -57, 21, -26, 31, 37, 32, -72, 77, -41, -111, 99, 62, 98, 117, -63, 103, -124, -96, -111, -84, -1, 7, -20, 47, 57, 15, -59, 66, 53, 47, 97, -94, 7, -56, 124, 83, 72, 81, 101, 77, 96, -40, 67, 112, 112, 112, 16, -127, 72, -127, -98, -73, -125, 78, 84, 107, 125, 12, 121, 57, -17, 68, -41, -75, -28, -26, -3, 125, -97, 82, -53, 8, -124, -118, -1, 47, 19, 64, -18, 38, 45, 84, 85, -52, 105, 109, -61, 1, -32, 72, -107, 20, -102, -40, -47, 67, 111, -72, -92, 88, -30, 61, -82, 116, -2, -127, 35, 72, 35, -51, 24, 21, -87, 21, 63, -82, -2, 70, -70, -118, -64, 15, -44, 93, 108, 62, -51, 84, -15, 72, 7, 102, -107, -112, -7, -72, 84, -24, -22, 53, 68, 68, 38, -64, 71, 27, 73, 40, -86, 111, -56, 22, 49, 88, -119, -42, 9, 121, 82, 22, -35, 113, 5, -112, 12, -71, 17, -31, 92, -4, 48, -40, -44, -41, -60, -82, -116, 5, 117, -95, -28, -54, 45, -32, 39, -119, -25, 126, -40, 95, -97, -88, -58, -3, -81, -84, -82, -122, 122, -20, 11, 74, 85, 117, -75, 77, 39, -81, -72, 108, 123, 104, 65, -60, 81, -104, 41, 63, -62, 65, 43, -84, -64, 35, -63, 78, -111, 55, -1, 123, 73, 125, -92, -76, -81, -106, 103, -125, 105, -102, 112, -57, 69, 30, 13, 41, 65, -47, 121, -111, 94, -21, -16, -87, -39, 87, 91, 48, 116, -80, 100, 25, -64, 87, 63, -7, -6, -104, 41, -17, -13, 32, 106, -35, -35, -119, 107, 66, 116, 119, -68, -94, 116, 40, 117, -36, 89, 69, -47, -47, -78, 89, -16, -15, -25, -29, -53, -72, -105, -83, -67, 110, 52, 76, -92, 90, 93, -34, -18, 105, -92, -76, -55, -80, 117, -122, -94, -59, 100, 96, -85, -16, 116, 84, 55, -72, -55, -63, 54, 111, -1, 116, 6, 5, 23, -62, -109, 93, -127, 113, 96, 66, -16, 29, -95, -77, -13, 74, -90, 122, -37, -109, -40, 46, -108, -73, 45, 91, -23, -117, 85, 111, -23, 83, 3, -75, -51, -68, 102, 81, -122, -38, 12, -115, -34, 91, -29, -114, 124, -31, 93, -92, -124, -31, -17, 23, 65, -27, -6, 105, 0, -127, -110, 66, 59, -107, -95, 38, 69, -58, 106, 55, 105, 23, -19, -38, 118, 85, -5, -14, 126, -42, 84, -11, 121, 75, 72, -88, 29, 20, -107, -128, -109, -124, 120, -109, -91, -102, -56, -45, -103, 61, -71, 123, -66, -75, 58, -84, -61, 59, 12, 74, 78, -58, -73, -59, -14, -24, 78, 37, 123, -56, -98, 120, -25, -49, -115, 41, 66, -90, -12, -88, -62, 44, 81, -59, 67, 78, -57, -128, -123, -108, -94, -34, 108, 115, 78, 112, -95, 48, 80, 94, 6, -84, 46, -6, 31, -35, 7, 75, -57, -41, -3, 3, -67, -89, 15, -36, -111, 115, -126, -111, 61, 42, 84, -107, -90, -103, 44, -29, -21, 75, 96, 42, 34, 74, 117, -10, -63, 122, -119, -78, -50, -78, 39, 112, 10, 29, -3, 79, -119, 50, 121, 29, -96, -87, 114, 86, -65, -104, -80, -43, -123, 41, 106, -22, 2, -2, -38, -30, 97, 44, -51, -115, 75, 86, -117, 68, -69, 57, 1, 79, 12, 95, -112, 92, 75, 84, -116, -74, 57, 73, 46, -71, 61, 97, 115, -71, 112, -96, 33, 29, -105, -18, -89, -27, 35, 42, -113, -22, -78, -27, 22, 5, 45, -56, -70, -82, -18, -40, -80, -30, -91, -8, -77, -18, 115, -81, 101, -46, 82, -90, 30, -105, -99, -25, -103, -110, -50, -66, 84, -57, -5, -22, -128, -18, 69, 52, -11, -111, -24, -85, -1, 12, 72, -31, -97, 81, -29, 68, -80, 73, 7, -55, 45, -33, -73, 127, 2, 4, 56, 74, -19, 78, -73, 106, 58, 10, 10, -75, -60, -16, 98, 46, 82, -45, 15, 79, 90, 43, -53, 37, -25, -29, 50, -72, 120, 73, -20, 110, 96, -48, -38, -5, 39, 18, -47, -109, 89, -45, 74, 60, -30, 85, -16, -57, -24, 118, 44, -67, -38, 72, -124, -76, -124, -78, -18, 18, -55, -7, -23, -63, -82, -17, -58, 36, 103, 100, -116, -73, 85, -22, 43, 24, 41, 1, -123, 52, 125, 68, 5, -80, 21, -124, 72, -82, 121, 66, 103, 123, 82, -37, -79, -124, -67, 66, 15, -29, 59, -90, -48, -37, -12, 40, 20, 66, 28, -95, 28, 68, -26, 80, 74, 64, 122, 58, 2, 91, -45, 115, 87, 77, 107, 5, -1, 68, 119, 109, -113, 94, 48, -67, 6, -120, -76, -34, -49, -121, 103, -25, 60, 119, -11, -99, -74, -104, 123, 21, -100, 77, -51, -122, -32, 16, 74, -90, -21, -9, 20, 82, -112, -1, -116, -119, 68, -21, 3, -65, 101, 30, 14, 49, -34, 38, -13, 105, 21, -98, 23, 114, 119, -109, 26, 91, -41, 73, 90, -34, -119, -66, 47, 38, 57, 111, 34, -77, -74, -100, 56, 30, -74, 79, 100, 73, -69, 28, -100, 10, 96, 68, -109, -87, -53, -44, -13, 48, -16, 79, -52, -60, -105, 23, 73, 32, -60, -47, -29, -17, 32, 52, -105, 118, -66, 82, 0, -96, 14, 74, -61, -107, 13, 14, -30, -5, 34, 78, 112, 0, -114, 109, 71, -7, 33, 110, -76, -66, 19, -117, 0, -124, -93, -116, -94, 12, 86, 4, 106, -77, -31, 64, -37, -105, 2, -99, -37, 42, 9, 103, 12, -44, -59, -23, -121, 31, 2, 60, 28, -96, -77, 16, -78, -75, 43, 1, 108, 52, 11, -18, 11, -79, -2, 106, 111, -51, 16, 12, 108, 79, 18, 49, 112, -67, 6, 66, 124, 98, 34, -94, 10, 17, 125, 93, -57, -58, 34, 86, -100, 101, -94, -97, 117, 48, 68, 35, 14, -46, -75, 45]

and for buffer:
[102, -32, 27, 23, 31, 111, -43, 124, 105, -122, 89, 13, 80, 62, 107, -21, 44, -93, -24, 100, -28, 18, -10, -55, 8, -7, 95, -82, -127, -125, -13, -14, 82, 93, -112, 33, 5, -43, 82, -89, -60, 111, 61, 5, 65, 1, -105, -65, -77, -119, 126, -118, -67, 32, -115, 106, -10, 75, 44, 101, 60, -110, -71, -27, 44, -111, 83, 83, 99, -25, -71, 12, -101, -35, -79, -115, 99, 107, 21, 118, -52, -107, -51, -122, 106, 12, 43, 23, 111, -60, -79, -20, 57, -28, 99, -106, -87, 74, -18, 71, 44, -26, -6, 80, -124, 34, -69, 27, 46, -15, -97, -71, 84, 30, -121, -36, 65, -46, 66, -34, 69, -127, -16, 100, 114, 38, -110, -24, -34, 82, 69, -75, 108, 42, 83, 103, -14, -54, 10, 85, 107, -1, 42, 41, 106, 4, 65, 122, -101, -45, 19, 32, -110, 61, 53, 73, -97, -119, -63, 96, 55, -103, -59, -84, -35, -64, 47, -58, -38, 8, 9, 3, 82, -109, -78, 124, 69, -2, -74, -55, 72, -26, 33, -110, 92, -48, 87, 81, 39, 95, -45, 121, -82, -75, -79, -104, 93, 37, -118, 108, 20, -49, -96, 74, -120, -89, 110, -36, 115, 69, 98, 99, -21, 48, 112, -42, -124, 7, 18, 32, -126, -47, 87, -33, -5, -83, -2, 61, 85, -31, -18, 109, -75, 75, -16, 57, 67, 90, 98, 54, -27, -79, 111, -119, 67, 106, -3, 43, 56, -56, -115, -118, 15, -80, -83, -83, 101, 116, 46, -89, 113, -38, 33, -49, -114, -90, -20, 59, -50, 27, -98, 41, 116, -73, 48, 92, -104, -5, 74, -91, 75, 49, 35, 9, 65, -47, 35, 17, 27, -112, -64, -80, -104, 0, -109, 55, 89, 11, 42, -22, 86, -125, 127, 1, -27, -64, 21, -119, 15, 79, 27, -2, -18, 36, 77, 47, -32, 81, -117, -107, 112, 52, 125, -116, -83, -34, -15, 31, -37, 19, -65, 28, -93, -102, 12, 83, 108, 88, -5, 121, -107, -71, -3, 65, 18, -99, -92, 103, -9, 57, 90, 93, 29, 13, -14, 122, 126, -32, 54, 90, -126, 10, -123, -94, 46, -90, -11, -93, -75, 23, -18, 36, 51, 8, 115, -122, -44, -59, -99, -127, 33, -107, -116, 11, -94, -94, 92, -51, 94, -15, -72, 78, 82, 10, -14, -81, -121, -57, -55, 4, -64, 89, -69, -26, 24, 10, -27, -44, 80, 3, 11, -7, 127, 109, 3, -20, -52, 92, 31, -80, -13, -127, -73, -61, -11, -1, 110, 52, 100, -72, -73, 29, -98, -55, -39, 14, 48, 71, 79, -60, -29, -61, 97, -48, -59, -61, -117, 89, -73, 95, -4, -8, -57, 21, -26, 31, 37, 32, -72, 77, -41, -111, 99, 62, 98, 117, -63, 103, -124, -96, -111, -84, -1, 7, -20, 47, 57, 15, -59, 66, 53, 47, 97, -94, 7, -56, 124, 83, 72, 81, 101, 77, 96, -40, 67, 112, 112, 112, 16, -127, 72, -127, -98, -73, -125, 78, 84, 107, 125, 12, 121, 57, -17, 68, -41, -75, -28, -26, -3, 125, -97, 82, -53, 8, -124, -118, -1, 47, 19, 64, -18, 38, 45, 84, 85, -52, 105, 109, -61, 1, -32, 72, -107, 20, -102, -40, -47, 67, 111, -72, -92, 88, -30, 61, -82, 116, -2, -127, 35, 72, 35, -51, 24, 21, -87, 21, 63, -82, -2, 70, -70, -118, -64, 15, -44, 93, 108, 62, -51, 84, -15, 72, 7, 102, -107, -112, -7, -72, 84, -24, -22, 53, 68, 68, 38, -64, 71, 27, 73, 40, -86, 111, -56, 22, 49, 88, -119, -42, 9, 121, 82, 22, -35, 113, 5, -112, 12, -71, 17, -31, 92, -4, 48, -40, -44, -41, -60, -82, -116, 5, 117, -95, -28, -54, 45, -32, 39, -119, -25, 126, -40, 95, -97, -88, -58, -3, -81, -84, -82, -122, 122, -20, 11, 74, 85, 117, -75, 77, 39, -81, -72, 108, 123, 104, 65, -60, 81, -104, 41, 63, -62, 65, 43, -84, -64, 35, -63, 78, -111, 55, -1, 123, 73, 125, -92, -76, -81, -106, 103, -125, 105, -102, 112, -57, 69, 30, 13, 41, 65, -47, 121, -111, 94, -21, -16, -87, -39, 87, 91, 48, 116, -80, 100, 25, -64, 87, 63, -7, -6, -104, 41, -17, -13, 32, 106, -35, -35, -119, 107, 66, 116, 119, -68, -94, 116, 40, 117, -36, 89, 69, -47, -47, -78, 89, -16, -15, -25, -29, -53, -72, -105, -83, -67, 110, 52, 76, -92, 90, 93, -34, -18, 105, -92, -76, -55, -80, 117, -122, -94, -59, 100, 96, -85, -16, 116, 84, 55, -72, -55, -63, 54, 111, -1, 116, 6, 5, 23, -62, -109, 93, -127, 113, 96, 66, -16, 29, -95, -77, -13, 74, -90, 122, -37, -109, -40, 46, -108, -73, 45, 91, -23, -117, 85, 111, -23, 83, 3, -75, -51, -68, 102, 81, -122, -38, 12, -115, -34, 91, -29, -114, 124, -31, 93, -92, -124, -31, -17, 23, 65, -27, -6, 105, 0, -127, -110, 66, 59, -107, -95, 38, 69, -58, 106, 55, 105, 23, -19, -38, 118, 85, -5, -14, 126, -42, 84, -11, 121, 75, 72, -88, 29, 20, -107, -128, -109, -124, 120, -109, -91, -102, -56, -45, -103, 61, -71, 123, -66, -75, 58, -84, -61, 59, 12, 74, 78, -58, -73, -59, -14, -24, 78, 37, 123, -56, -98, 120, -25, -49, -115, 41, 66, -90, -12, -88, -62, 44, 81, -59, 67, 78, -57, -128, -123, -108, -94, -34, 108, 115, 78, 112, -95, 48, 80, 94, 6, -84, 46, -6, 31, -35, 7, 75, -57, -41, -3, 3, -67, -89, 15, -36, -111, 115, -126, -111, 61, 42, 84, -107, -90, -103, 44, -29, -21, 75, 96, 42, 34, 74, 117, -10, -63, 122, -119, -78, -50, -78, 39, 112, 10, 29, -3, 79, -119, 50, 121, 29, -96, -87, 114, 86, -65, -104, -80, -43, -123, 41, 106, -22, 2, -2, -38, -30, 97, 44, -51, -115, 75, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...

因此,我首先得到1008人的同样数据,此后,我再也没有获得任何数据。

任何想法如何纠正?

问题回答

I had to solve a similar error. And the only related question was in this thread, which was still not solved. So had to search for reason and solution myself :).

The reason is that Android bluetooth seems to send the data in bunches of 1008 Bytes. So you need to read from the stream in a while loop and concatenate the received bytes.

在这里,应当如何改写你的法典:

byte[] buffer = new byte[4096];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytes;

while ((bytes = inputStream.read(buffer, 0, buffer.length)) > -1) {
          baos.write(buffer, 0, bytes);
          baos.flush();
}
byte[] message = baos.toByteArray();

// =================== other side =============================
byte[] message = Tools.concatByteArray(response, authorizationMessage);
outputStream.write(message);
outputStream.flush();
outputStream.close(); // <-- important! so the receiver knows that it is the end of data

Did you set any buffer size? Normally you would read until there is no more data.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...