2017-07-13 3 views
-1

CountDownTimerクラスにどのようにアラームを追加しますか?私はそれがそれに付属する方法onFinish()になるだろうと思うが、ちょうどそれについて行くだろうか?いくつかのコードは多くの助けになります。CountDownTimerにアラームを追加するには?

+1

developer.android.comはあなたの親友です。https://developer.android.com/reference/android/os/CountDownTimer.html –

答えて

0

CountDownTimerを拡張したクラスを作成し、on finishメソッドをオーバーライドしてそこにアラーム関数を追加します。

object : NewCountDownTimer(3000, 1000) { 
     override fun onFinish() { 
      super.onFinish() 
      Timber.d("Test new countdowntimer2") 
     } 
     override fun onTick(millisUntilFinished: Long) { 

     } 

    }.start() 




open class NewCountDownTimer(millisInFuture: Long, millisUntilFinished:Long) : CountDownTimer(millisInFuture, millisUntilFinished) 
{ 
    override fun onFinish() { 
     Timber.d("Test new countdowntimer") 
     //Add alarm function Here 
    } 

    override fun onTick(millisUntilFinished: Long) { 
    } 

} 
関連する問題