[Android] Thread Button sleep
- by user557475
Hello
For my project,i´am trying to execute a Method every 10 seconds when i click a button "A"
and it should stop when i click the button again (kind of on/off).
this is what i reached :-/ :
ButtonA.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
showCurrentLocation();
Methodexecute();
}
}, 10000);
}
}
});
how can i repeat executing this method every 10 seconds until the button is clicked again.
thanks