Visually, I\'m expecting my app to show four Toasts in the following order:
public void delayedRandomCue(final long a){
didPlayerRespond = true;
this happens first
createToast("start of delayed RandomCue Method");
randomCue();
Thread delay = new Thread() {
public void run() {
This happens in the background, asynchronously.
try {
createToast("start of delay");
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}finally {
This happens in the background, after asynchronously running and completing
createToast("end of delay");
didPlayerRespond = false;
}
}
};delay.start();
This comes second because it is executed synchronously with the rest of the method.
createToast("end of delayed RandomCue Method");
}
This doesn't answer you question about the order of the toasts, but are you sure , when you say
The problem I'm running into is the code provided in the link (method called from within an onclick method) is supposed to change the image, set a bool value to false,wait 1.5 seconds, and then change the same bool value back to true.
While the bool value is true, the method that changes the pictures is supposed to be skipped but that's not the case and I don't know why but i think it's something to do with the code in the gists I created below.
that this is the case?
It looks more like , if the boolean is set to false, the other method that changes the pictures needs to be skipped, and as long as it is true, it needs to periodically change the pictures.
Try that, and maybe your image won't change very quickly after the user did trigger the onClick.