Code example for Timer

Methods: cancel, purge

0
        return true; 
    } 
     
    @Override 
    public void onStop(){ 
    	timer.cancel();
    	timer.purge();
    	timer = null;
    	super.onStop(); 
    } 
     
    @Override 
    public void onRestart(){ 
    	super.onRestart(); 
    	if(timer==null){
    		timer = new Timer();
    		timer.schedule(new MyTask(), 0,5000);
    	} 
    } 
}