I can’t figure out how to make an HH:MM:SS Countdowntimer using Milliseconds.
I need to make a CountdownTimer telling how many hours, minutes, and seconds remain until the next day. Here is my code:
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
long timer = prefs.getLong("TIME", 86400000);
new CountDownTimer(timer, 1000) {
public void onTick(long elapsed) {
time.setText(elapsed/3600000+":"+elapsed/1440000+":"+elapsed/?);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong("TIME",elapsed);
editor.commit();
}
public void onFinish() {
}
}.start();
P.S: Also, it will have to save the time left until last check. I look forward urgently to hearing from you guys. Thank you in advance!
Your calculation is wrong, it should be: