Android: executando o encadeamento em um loop com onTouchListener ()
Oi no meu aplicativo, existem 8 botões. Cada botão é configurado onclickListener () quando é clicado, a String é escrita pelo socket. Agora eu quero que, quando eu pressionar e segurar o botão, o String deve ser escrito em um loop. Aqui está o que estou tentando fazer.
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 alguma forma eu não sei porque não está funcionando. start, execute (string, string) executa o thread na classe AsyncTask para criar um fluxo de soquete e saída.