Skip to content

Instantly share code, notes, and snippets.

@hiwanz
Created October 1, 2014 15:28
Show Gist options
  • Save hiwanz/4407146422c7d76b255a to your computer and use it in GitHub Desktop.
Save hiwanz/4407146422c7d76b255a to your computer and use it in GitHub Desktop.
An Android timer demo call
//need to import android.os.Handler;
final Handler h = new Handler();
h.postDelayed(new Runnable()
{
private long time = 0;
@Override
public void run()
{
// do stuff then
// can call h again after work!
time += 1;
Log.d("TimerExample", "Going for... " + time);
// 1 second delay (takes millis)
h.postDelayed(this, 1000);
}
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment