Android: Timer

[java]
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

new CountDownTimer(10000, 100) {

public void onTick(long millisecondsUntilDone) {
Log.i("Seconds Left!", String.valueOf(millisecondsUntilDone / 1000));
Toast.makeText(MainActivity.this, "" + String.valueOf(millisecondsUntilDone / 1000), Toast.LENGTH_SHORT).show();
}

public void onFinish() {
Log.i("We’re done!", "No more countdown");
}
}.start();</pre>
[/java]

Comments (1)

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.