private class WriteThread extends Thread{
byte[] data;
WriteThread(byte[] dataToSend)
{
this.data = dataToSend;
setPriority(Thread.NORM_PRIORITY);
}
public void run()
{
if (data[0] == (byte)0xB8 && data[1] == (byte)0x12)
{
{
try {
for (int i =0 ;i < data.length ; i++) {
outputStream.write(data[i]);
outputStream.flush();
this.sleep(4);
}
} catch (Exception ex) {
Log.d("SLEEP", Objects.requireNonNull(ex.getMessage()));
}
}
}
else
try {
outputStream.write(data);
} catch ( Exception ex)
{
Log.d("SLEEP", Objects.requireNonNull(ex.getMessage()));
}
}
}