|
|
|
|
|
|
|
|
} catch (SocketException | UnknownHostException e) { |
|
|
} catch (SocketException | UnknownHostException e) { |
|
|
throw new RuntimeException(e); |
|
|
throw new RuntimeException(e); |
|
|
} |
|
|
} |
|
|
mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText("Communication running")); |
|
|
|
|
|
|
|
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText("Communication running")); |
|
|
} |
|
|
} |
|
|
private class ReceiveThread extends Thread { |
|
|
private class ReceiveThread extends Thread { |
|
|
private StringBuffer rxStringBuffer = new StringBuffer(); |
|
|
private StringBuffer rxStringBuffer = new StringBuffer(); |
|
|
|
|
|
|
|
|
rxString = new String(rxPacket.getData()); |
|
|
rxString = new String(rxPacket.getData()); |
|
|
if(!previousRxString.equals(rxString)) { |
|
|
if(!previousRxString.equals(rxString)) { |
|
|
rxStringBuffer.append(rxString).append("\n"); |
|
|
rxStringBuffer.append(rxString).append("\n"); |
|
|
mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer)); |
|
|
|
|
|
|
|
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer)); |
|
|
previousRxString = rxString; |
|
|
previousRxString = rxString; |
|
|
} |
|
|
} |
|
|
|
|
|
|