Thread: Timer issues
View Single Post
Old 10-08-2014, 04:41 PM   #5
ChronosDragon
Junior Member
ChronosDragon began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Oct 2014
Location: Seattle area
Device: Kindle 4 Non-Touch
Quote:
Originally Posted by hawhill View Post
Timer.schedule() schedules the task once. So everything is working as it should. OP is probably looking for Timer.scheduleAtFixedRate(). Documentation is sparse, but available: http://kdk-javadocs.s3.amazonaws.com...til/Timer.html Note the difference between "fixed delay" and "fixed rate".
Thanks for the advice. I'd actually found that documentation at one point but forgotten about it (because it wasn't immediately useful to my problem at the time). Will bookmark for future reference.

I don't see anything in there about why fixed-delay and fixed-rate would be any different, but if CPU sleeping was an issue I guess I could see why one would work over the other. However, I don't think either of them are working: Just updated my code to use the scheduleAtFixedRate method and it's still not running the update (again unless you lock/unlock):

Huge phone screenshot

Updated portion of code:
Code:
            t = new Timer();
            t.scheduleAtFixedRate(
                new UpdateTimeTask(this),
                new Date(),  // Execute first now
                15000L        // Spacing between executions (15 s)
            );
(I also made the period argument a long literal because...well, I didn't really think there would be an interpretation error there but I'm trying to think of every possibility at this point)

(Also, just to be sure it was indeed running an updated version of the app, I had a couple of intermediate builds where I was playing with adding a version label. Didn't figure out any solution for the moment but I know it's running the new code.)

Thanks again for the help
ChronosDragon is offline   Reply With Quote