Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7588997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:03:49+00:00 2026-05-30T20:03:49+00:00

im working on a audio profile switcher for android and as part of the

  • 0

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:

timer.scheduleAtFixedRate( new TimerTask() {
public void run() {.....}, 0, nextUpdateInterval);

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: long entirePeriodDiff = toTimeMiliseconds - fromTimeMiliseconds;

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

and then i update the nextUpdateInterval: nextUpdateInterval = entirePeriodDiff - elapsedTime;

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:03:50+00:00Added an answer on May 30, 2026 at 8:03 pm

    As per android doc:

    With fixed-rate execution, the start time of each successive run of a task is scheduled without regard for when the previous run took place. This may result in a series of bunched-up runs (one launched immediately after another) if delays prevent the timer from starting tasks on time.

    I think that could be the reason, may be you need to consider alternative ‘fixed period’

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an audio project I'm working on using BASS from Un4seen. This library
I am working on a project that plays audio for part of the program.
I'm working on an app that plays audio continuously using the waveOut... API from
I am working with jQuery mobile and using the HTML5 audio tag. I have
Currently I am working on audio streaming on android. All method I have written
I'm working on an application that processes audio data. I'm using java (I've added
So I am working on this application that deals with audio, and I have
I'm working on an application that samples audio and needs to do real time
I have been encountering this error for my project, which involves working with Digital
I'm working through a chapter about iPhone audio and have come across a section

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.