0
MainActivity.this.in = MainActivity.this.uart.getInputStream();
int re = in.read();

All of above is my part of code. I want to read a digit from peripheral device. if the waiting time is over 3 seconds. Stop! Then appear a warning information! But I don't know how to interrupt the wait.

1 Answers1

0

try set so_timeout to the corresponding socket like Socket.setSoTimeout(3000L) before you call in.read();

BlackJoker
  • 3,099
  • 2
  • 20
  • 27
  • Thanks for your answer!But I am not doing network programming. – user2201330 Jun 24 '13 at 07:40
  • Cursor cursor = DBHelper.getInstance(MainActivity.this).select(); ArrayList all = new ArrayList(); while (true) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor .moveToNext()) { all.add(cursor.getInt(0)); } label: for (int sstr : all) { final int forWarningInfo = sstr; try { out.write(hexStringToBytes(sendOrder[sstr - 1])); } catch (IOException e) { e.printStackTrace(); } – user2201330 Jun 24 '13 at 07:43