Code example for Timer

Methods: scheduleAtFixedRate

0
     
       
    // emulate music play 
    public void beginLrcPlay(){ 
        if(mTimer == null){
            mTimer = new Timer();
            mTask = new LrcTask();
            mTimer.scheduleAtFixedRate(mTask, 0, mPalyTimerDuration);
        } 
    } 
     
    public void stopLrcPlay(){ 
        if(mTimer != null){
            mTimer.cancel();
            mTimer = null;
        } 
    } 
     
    class LrcTask extends TimerTask{
         
        long beginTime = -1;