Code example for Timer

Methods: cancel

0
        } 
    } 
     
    public void stopLrcPlay(){ 
        if(mTimer != null){
            mTimer.cancel();
            mTimer = null;
        } 
    } 
     
    class LrcTask extends TimerTask{
         
        long beginTime = -1;
         
        @Override 
        public void run() { 
            if(beginTime == -1) {
                beginTime = System.currentTimeMillis();
            } 
             
            final long timePassed = System.currentTimeMillis() - beginTime;