0

I want to log when something happened and delay 1 minitues. so I use a timer and timertask live this:

 private Timer _checkTimer;
 private boolean _timerStart = false;
 private void requestPlayPosterItem(long id) {
        //
        if(_timerStart && _checkTimer != null ){
            _checkTimer.cancel();
        }
        _checkTimer = new Timer();
        _checkTimer.schedule(new TimerTask(){

            @Override
            public void run() {
                _timerStart = false;
                // do log 
            }

        }, 30000);
        _timerStart = true;
// others -----
}

and at activity onPause(), I cancel the timer too:

        if(_checkTimer != null && _timerStart){
        _checkTimer.cancel();
    }

my question: _checkTimer can reuse? is there resource leak(timer)?

BollMose
  • 3,002
  • 4
  • 32
  • 41

0 Answers0