3

I'm trying to code the game loop for an android game, however, i've come across this error when trying to access the current time (you know, for FPS management etc)

"SystemClock() is not public in 'android.os.SystemClock'. Cannot be accessed from outside package"

My code:

import android.os.SystemClock;

//...

SystemClock clock = new SystemClock();

Can you help me please? ^_^

Tirafesi
  • 1,297
  • 2
  • 18
  • 36
  • You do not create an instance of `SystemClock`. You call `static` methods on `SystemClock`, such as `uptimeMillis()`. – CommonsWare May 03 '16 at 13:50
  • Ah, thank you! I thought it worked like random number generator where i need to create an instance of the generator :/ – Tirafesi May 03 '16 at 13:53

1 Answers1

1

SystemClock exposes static methods. So you should access them like this:

SystemClock.sleep(1000);
boolean b = SystemClock.setCurrentTimeMillis(1000)
long l = SystemClock.currentThreadTimeMillis();
Guillaume Barré
  • 4,168
  • 2
  • 27
  • 50