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

  • Home
  • SEARCH
  • 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 1054927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:28:58+00:00 2026-05-16T17:28:58+00:00

I have an Android app which needs to play a sound resource on a

  • 0

I have an Android app which needs to play a sound resource on a timed interval, say every 120 seconds.

I know how to access the sound resources and play them, however it’s time timer part I’m not sure of. What’s the best approach?

  • 1 1 Answer
  • 3 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-16T17:28:59+00:00Added an answer on May 16, 2026 at 5:28 pm

    I ended up ditching the Timer approach and used a Handler instead after stumbling upon an example at android-labs.

    So, instead of spawning the Timer and TimerTask in my Activity’s onCreate, I declared this private Handler with in-line Runnable:

    private Handler _playRandomSoundHandler = new Handler();
    private Runnable _playRandomSoundTask = new Runnable() {
        public void run() {
            SoundManager.playRandom();
            _playRandomSoundHandler.postDelayed(_playRandomSoundTask, Prefs.getDelayInMilliseconds(getApplicationContext()));
        }
    };

    Also, I had to add code to my Activity’s onResume and onPause:

    @Override
    protected void onResume() {
        super.onResume();
        _playRandomSoundHandler.postDelayed(_playRandomSoundTask, Prefs.getDelayInMilliseconds(this));
    }
    
    @Override
    protected void onPause() {
        super.onPause();
        _playRandomSoundHandler.removeCallbacks(_playRandomSoundTask);
        SoundManager.stop();
    }

    This approach seems to work great.

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

Sidebar

Related Questions

I have an android app which has native code. The native code needs to
I have an android app which needs to be signed using a specific keystore
I have an android app which let the user to submit a form ,
I have an Android app which is crashing on some phones, and not on
I have an Android app which calculates poker odds ( Shufflebot if you're interested).
I have an android app which gives the user the option of loading a
I have an Android app which includes an activity called Help This uses a
I have made an android app which working fine. I implemented the Login functionality
I have been trying to implement an upgrade plan for my Android app which
I have an Android app that I had working a few months ago which

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.