i am using a class which extends Handler class to update my activity UI. The code is as follows in side main activity,
public class RefreshHandler extends Handler {
public void handleMessage(Message msg) {
Homeform.this.updateUI();
}
public void sleep(long delayMillis) {
this.removeMessages(0);
sendMessageDelayed(obtainMessage(0), delayMillis);
}
};
private void updateUI(){
Log.v(""," I am inside Update UUI=====================");
refresh();
mRedrawHandler.sleep(5000);
}
And i had call this method handleMessage() on the object of RefreshHandler as follows
mRedrawHandler = new RefreshHandler();
mRedrawHandler.handleMessage(new Message());
But here i am facing one problem that it is running after closing my application also .
please solve my problem to stop this handler when close this application.
Thank you..
onDestroy, call remove
mRedrawHandler.removeMessages(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With