OutputStream.write() никогда не заканчивается ⇐ JAVA
OutputStream.write() никогда не заканчивается
I have a car with a bluetooth interface that I connect to using my android app. Robot is programmed so that when he gets a digit 1-5, he makes an action. 1 - drive forward 2 - drive backward 3 - turn left 4 - turn right 5 - stop I have 5 buttons in my app. Their events' look like this
public void button1(View view){ socket.write("1"); } where socket is the class that holds BluetoothSocket and makes a connection and has write function:
public void write(String signal) { try { OutputStream.write(signal.getBytes()); Log.d("#Signal", " connected"); } catch (IOException e) { } } AND! When I connect, and press for example button that sends 2, robot starts moving backward but I don't get message from line
Log.d("#Signal", " connected"); So it looks like write(byte[] buffer) function never ends it's procedure. After pressing one button, when I try to press another one, it doesn't work. Like OutputStream.write() still tries to write something. I don't know why this happens, any solutions?
Источник: https://stackoverflow.com/questions/350 ... never-ends
I have a car with a bluetooth interface that I connect to using my android app. Robot is programmed so that when he gets a digit 1-5, he makes an action. 1 - drive forward 2 - drive backward 3 - turn left 4 - turn right 5 - stop I have 5 buttons in my app. Their events' look like this
public void button1(View view){ socket.write("1"); } where socket is the class that holds BluetoothSocket and makes a connection and has write function:
public void write(String signal) { try { OutputStream.write(signal.getBytes()); Log.d("#Signal", " connected"); } catch (IOException e) { } } AND! When I connect, and press for example button that sends 2, robot starts moving backward but I don't get message from line
Log.d("#Signal", " connected"); So it looks like write(byte[] buffer) function never ends it's procedure. After pressing one button, when I try to press another one, it doesn't work. Like OutputStream.write() still tries to write something. I don't know why this happens, any solutions?
Источник: https://stackoverflow.com/questions/350 ... never-ends
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Безопасен ли метод WriteTo(OutputStream) ByteArrayOutputStream для большого файла?
Anonymous » » в форуме JAVA - 0 Ответы
- 22 Просмотры
-
Последнее сообщение Anonymous
-