Android Dev: Timer not honoring dynamic interval period
<p>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:</p>

<p><code>timer.scheduleAtFixedRate( new TimerTask() {
public void run() {.....}, 0, nextUpdateInterval);</code></p>

<p>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...</p>

<p>nextUpdateInterval calculation: <code>long entirePeriodDiff = toTimeMiliseconds - fromTimeMiliseconds;</code> </p>

<p>then once a profile is found, i calculate the elapsedTime like so: <code>long elapsedTime =  rightNowDate.getTime() - fromDate.getTime();</code></p>

<p>and then i update the nextUpdateInterval: <code>nextUpdateInterval = entirePeriodDiff - elapsedTime;</code></p>

<p>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 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 ideas?</p>
