I am trying to stop Runnable using removeCallbacks, but somehow it wont stop. - here are my variables
private int mInterval = 2000; // 2 seconds by default, can be changed later
private Handler mHandler = new Handler();
and my runnable
Runnable mStatusChecker = new Runnable() {
@Override
public void run() {
try {
checkPayNow();
} finally {
// 100% guarantee that this always happens, even if
// your update method throws an exception
mHandler.postDelayed(mStatusChecker, mInterval);
}
}
};
and the method I am running untill it gives me a certain value then i stop
public void checkPayNow(){
if (!url.isEmpty()){
//url now has text
mHandler.removeCallbacks(mStatusChecker);
}else {
//no text yet
}
}