[Android] Processing "while pressed" Button?

Actually the problem is, the application is transmitting data over the network timer.

Something like:
Socket s = new Socket(ip, port);<br>
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));<br>
Timer1 ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor();<br>
timer1.scheduleAtFixedRate(new Runnable() {<br>
public void run() {<br>
out.write("default message");<br>
}, 10, Long.parseLong("100"), TimeUnit.MILLISECONDS);<br>

How to handle a situation — "while the button is pressed do out.write("some message"); if pressed then make out.write("default message"); on"

In standard processors I found only OnClick and OnLongClick, both are not suitable.
October 8th 19 at 02:59
1 answer
October 8th 19 at 03:01

Find more questions by tags Android