Open vidyajejurkar opened 7 years ago
public void run() {
byte[] buffer;
ArrayList
// Keep listening to the InputStream while connected
while (true) {
try {
int data = mmInStream.read();
if (data == CheckCode.FLAG_BEGIN) { //_fix this_
arr_byte.clear();
arr_byte.add(data);
} else if (data == CheckCode.FLAG_END) { //_fix this_
arr_byte.add(data);
buffer = new byte[arr_byte.size()];
for (int i = 0; i < arr_byte.size(); i++) {
buffer[i] = arr_byte.get(i).byteValue();
}
mHandler.obtainMessage(BluetoothState.MESSAGE_READ, buffer.length, -1, buffer).sendToTarget();
arr_byte.clear();
} else {
arr_byte.add(data);
}
} catch (IOException e) {
connectionLost();
break;
}
}
}
Still not working :-(
public void run() {
byte[] buffer;
ArrayList
// Keep listening to the InputStream while connected
while (true) {
try {
int data = mmInStream.read();
if(data == 0x0A) {
} else if(data == 0x0D) {
buffer = new byte[arr_byte.size()];
for(int i = 0 ; i < arr_byte.size() ; i++) {
buffer[i] = arr_byte.get(i).byteValue();
}
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothState.MESSAGE_READ
, buffer.length, -1, buffer).sendToTarget();
arr_byte = new ArrayList<Integer>();
} else {
arr_byte.add(data);
}
} catch (IOException e) {
connectionLost();
// Start the service over to restart listening mode
BluetoothService.this.start(BluetoothService.this.isAndroid);
break;
}
}
}
i have the same issue, but i use sample can send data, i put the code in my project is not working.
i solve it but i dont know why
All is working except send functoin. API 25
Need help.I am not able to send data to device.