Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SystemClock() is not public in 'android.os.SystemClock'

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? ^_^

like image 577
Tirafesi Avatar asked Dec 13 '25 21:12

Tirafesi


1 Answers

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

SystemClock.sleep(1000);
boolean b = SystemClock.setCurrentTimeMillis(1000)
long l = SystemClock.currentThreadTimeMillis();
like image 65
Guillaume Barré Avatar answered Dec 15 '25 11:12

Guillaume Barré



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!