我正在制作与MiBand2通信的安卓应用程序,我正在使用这个代码- https://github.com/fraperleo/MonitoringMiBand2。如何从接收到的字节中解析出步数?接收字节- 12,93,4,0,0,-71,2,0,0,24,0,0,0。Band显示1117步。
发布于 2018-09-05 05:19:45
您可以使用类ByteBuffer包装字节并获得整数值。
byte[] miBandResponse = {12, 93, 4, 0, 0, -71, 2,24};
int steps = ByteBuffer.wrap(miBandResponse).getInt();您也可以使用BigInteger
byte[] miBandResponse = {10, -116}; //2700 steps.
int i = new BigInteger(miBandResponse).intValue();我希望它能对你有所帮助。
https://stackoverflow.com/questions/52174034
复制相似问题