Runnable behaviour differs debug/live - TechRepublic
Question
June 3, 2013 at 01:30 AM
davidw32

Runnable behaviour differs debug/live

by davidw32 . Updated 13 years ago

Could anyone help with a problem to do with an android runnable please? It behaves correctly in debug but not when run live!
I have a layout with a canvas and 2 textviews. The canvas has a simple game and a runnable is used to alter the sprites many times a second. Based on some actions, a bit of code in the runnable sometimes updates a textview (a score). That works fine.
I wanted to add a timer/countdown to the game, so logged the time at the start
startTime = System.nanoTime()
and in the runnable added
float deltaTime = (System.nanoTime() – startTime) / 100000000000.0f;
if ((int)deltaTime > timerCount) {
timerCount = timerCount + 1;
((TextView)findViewById(R.id.countdown)).setText(Integer.toString(timerCount));
Log.i(TAG, “Updating countdown”);
}
In debug it works fine but when run live nothing happens – not even the log.
I added a clause to finish the activity if timerCount > 2: works in debug, not in live.
Any suggestions of what might be going on?

This discussion is locked

All Comments