Hi All,
im working on a audio profile switcher for android and as part of the entire project, i have a service that is running in the background using the following timer code:
what im noticing is that the timer is not honoring the dynamically generated next update interval period...the nextUpdateInterval is declared as private static long which is initialized to 30000 (30 seconds) for the first run....then once a profile is found, i do some math and update the nextUpdateInterval...i have converted the nextUpdateInterval value back out to hours/minutes for debugging purpose, and the calculation is working as expected...like it shows me in hours and minutes, when the next timer execution should take place...
nextUpdateInterval calculation:
then once a profile is found, i calculate the elapsedTime like so:
and then i update the nextUpdateInterval:
one example scenario: Profile of 'Work' is set from 9AM to 4:30PM, the service/app is executed at 2:02PM (EST), my toast message is executing constantly (indicating the 'run' method in the timer is being executed) and is acting as a count down telling me how much time is left...in this case 2:28 and decreasing...ideally this should not display until the 2:28 is up...
any suggestions?
Thanks!
im working on a audio profile switcher for android and as part of the entire project, i have a service that is running in the background using the following timer code:
Code:
timer.scheduleAtFixedRate( new TimerTask() { public void run() {.....}, 0, nextUpdateInterval);
nextUpdateInterval calculation:
Code:
long entirePeriodDiff = toTimeMiliseconds - fromTimeMiliseconds;
Code:
long elapsedTime = rightNowDate.getTime() - fromDate.getTime();
Code:
nextUpdateInterval = entirePeriodDiff - elapsedTime;
any suggestions?
Thanks!