Are there any major differences between CountDownTimer and AlarmManager? I don’t mean syntax or how to use it but wondering if there are such tasks when you certainly can say that I should use one of them, not another?
Simple example, I have to launch some action once a minute. What should I use? CountDownTimer or AlarmManager? How it depends?
Are there any major differences between CountDownTimer and AlarmManager ? I don’t mean syntax
Share
AlarmManagergenerally is used for purposes where your application is closed or must execute some repeating task(s). It is also slightly less precise thanTimerorHandler.CountDownTimeris used more for running a specific task at a duration (onFinish), and being updated periodically until it executes (onTick).In your specific case, I believe you should be using
AlarmManager, since it can repeat indefinitely. If you want something to execute every second for 10 seconds, for example, useCountDownTimer.