I want to show data in Textview for 2 second time.So I recieved data from arduino that not have a delay between I use serialwrite.I use InputStream and DatainputStream for recieved data.It's still have a problem when data show in textview.It will chance to the next data suddenly.Is there any method for hold it for 2 sec and chance it to next ? I write code in android Studio . .
private void receive(byte[] data) {
InputStream is = null;
DataInputStream dis = null;
try {
is = new ByteArrayInputStream(data);
dis = new DataInputStream(is);
while (dis.available() > 0) {
byte[] b = new byte[data.length];
dis.read(b, 0, 8);
count++;
String part = HexDump.dumpHexString(b).substring(HexDump.dumpHexString(b).indexOf("E7 0"), HexDump.dumpHexString(b).indexOf("0A"));
if (part.contains("E7 01")) {
//receive_text2.setText((part));
show_text(receive_text2,part);
}
if (part.contains("E7 02")) {
receive_text3.setText(String.valueOf(1000*unsiged(b[5])+100*unsiged(b[6])));
}
if (part.contains("E7 03")) {
receive_text4.setText((part));
}
if (part.contains("E7 05")) {
receive_text5.setText((part));
}
receive_text6.setText(String.valueOf(count));
}
}catch (Exception e){
receive_text2.append("");
receive_text3.append("");
receive_text4.append("");
receive_text5.append("");
receive_text6.append("");
}
}