I have set up a callback to run every one second, I cannot seem to stop the process. I have asked this question on 4 different forums and no one can seem to answer this question it is very frustrating. Is there a way to stop this?
The method
void startCallbackTimer() {
callbackRunnable = new Runnable() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void run() {
if (isIni&&dateSent&&UpdateSent) {
Result result = per.getResult();
Update(result);
}
callbackHandler.postDelayed(this, 1000);
}
};
callbackHandler.postDelayed(callbackRunnable, 1000);
}
I have tried to call multiple times:
callbackHandler.removeCallbacks(callbackRunnable);
But no luck, please can anyone answer this question i am stuck.