Android: ejecutando el hilo en un bucle con onTouchListener ()
Hola, en mi aplicación hay 8 botones. Cada botón se configura en clickListener () cuando se hace clic en la cadena se escribe en el socket. Ahora quiero que cuando presione y mantenga presionado el botón, la cadena deba escribirse en un bucle. Esto es lo que estoy tratando de hacer.
bLeft.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent event) {
// TODO Auto-generated method stub
MyThread start = new MyThread();
boolean isReleased = event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL;
boolean isPressed = event.getAction() == MotionEvent.ACTION_DOWN;
while (isPressed) {
start.execute(ip, "left");
break;
}
return false;
}
});
De alguna manera no sé por qué no funciona. start, execute (string, string) ejecuta el hilo en la clase AsyncTask para crear un socket y una secuencia de salida.