title: Set timer for executing task multiple times
body: <p>I have a requirement, where I need to create a timer task which will execute the function after every 10 sec. There is reset <code>Button</code>, on click of that reset <code>Button</code> I want to reset my time from 10 sec to 30 sec. Now after 30 sec when it execute the function I need to reset my timer again to 10 sec. I tried using <code>Handler</code> , <code>TimerTask</code> and <code>CountDownTimer</code>, but not able to achieve the requirement. Can anyone suggest me the best way of solving this problem</p>
  
  <pre><code>// OnCreate of Activity
  if (timerInstance == null) {
              timerInstance = Timer()
              timerInstance?.schedule(createTimerTask(), 10000L, 10000L)
  }
  
  private fun createTimerTask(): TimerTask {
          return object : TimerTask() {
              override fun run() {
                  Log.d("TimerTask", "Executed")
                  //presenter?.onCountdownTimerFinished(adapter.activeCallList, adapter.previousPosition)
              }
          }
  }
  
  //On Reset Button Click
  timerInstance?.cancel()
  timerInstance = Timer()
  timerInstance?.schedule(createTimerTask(), 30000L, 30000L)
  </code></pre>