stopping android handler loop
- by venka reddy
Hi, 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 is it is running after closing my application also .
please solve my problem to stop this handler when close this application.
ThanQ.....