stopping android handler loop

Posted by venka reddy on Stack Overflow See other posts from Stack Overflow or by venka reddy
Published on 2010-04-12T09:57:32Z Indexed on 2010/04/12 10:03 UTC
Read the original article Hit count: 336

Filed under:

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.....

© Stack Overflow or respective owner

Related posts about android