1

What I want is to measure time with milliseconds, but using Chronometer has the problem that it has no accuracy (its most resolution is seconds) I've seen this: Show miliseconds with Android Chronometer But I haven't been able to make it work. Maybe I should use another Object? Any idea?

Community
  • 1
  • 1
ArcDare
  • 3,106
  • 4
  • 27
  • 38
  • [Show miliseconds with Android Chronometer](http://stackoverflow.com/questions/2979835/show-milliseconds-with-android-chronometer) what problem do you have with the code in the above link – Abhay Kumar Nov 04 '11 at 10:29
  • 1
    Have you tried System.currentTimeMillis() ? Or does it not serve your purpose? – c05mic Nov 04 '11 at 10:29
  • 1
    I'm testing it and it just not works. FormatTime? I don't have that function! Even if I try to show only "i" it crashes. I don't know what I'm doing wrong =( – ArcDare Nov 04 '11 at 10:48
  • This looks like it might work: http://developer.android.com/resources/articles/timed-ui-updates.html I'll let you know – ArcDare Nov 04 '11 at 10:56
  • 1
    Using System.currentTimeMillis() and playing with it works! Thank you very much! – ArcDare Nov 04 '11 at 11:09

1 Answers1

1

Ok, this is the easiest way: When you want to start the chrono:

StartTime=System.currentTimeMillis(); // I've defined StartTime as a double

Then, you just have to do compare current time with StartTime:

millis=System.currentTimeMillis()-StartTime; // Millis is a double too
// If you'd want seconds, add seconds=(int) milis/1000; etc.

And so you can play with milis (Has it arrive to the time I wanted? How many time is it counting? ...)

ArcDare
  • 3,106
  • 4
  • 27
  • 38