I would like to ask a general post Delay question. So I'm using this method in my app, but it seems it is not working as I have expected.
What I'm trying to check is say :
private boolean privateVariable = false // private instance field
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if(privateVariable)) {
//DO SOMETHING
}
}
}, 5000);
and privateVariable got updated as true within the 5 seconds of delay. Does DO SOMETHING gets executed??
In other words, when we use postdelay method, are we saving the variables when we delay it and use it after certain amount of delay, or are we using the updated variable when the run() gets executed after 5 seconds? It seems in my app it saves it, so even though I change it in between the 5 second delay, it uses the original one that it was when I made the new handler.
If it uses the saved one, can you please inform me of a way to use the updated value after certain amount of time?
Thank you in advance.