I ended up working with a handler and it works great:
import android.os.Handler;
private Handler timeHandler = new Handler();
timeHandler.removeCallbacks(updateTime);
timeHandler.postDelayed(updateTime, 100);
private Runnable updateTime = new Runnable() {
public void run() {
timeHandler.postDelayed(this, 100);
currentTimeMillis = currentTimeMillis + 100;
}
I added wakeLock so that the processor does not sleep if the screen is locked, and the front-end service is also used. It was exactly in the tests that I have done so far.
source
share