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 7890717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:25:43+00:00 2026-06-03T06:25:43+00:00

Some users are getting (ANR keyDispatchingTimedOut) error with my app on line threadAudio.start() private

  • 0

Some users are getting (ANR keyDispatchingTimedOut) error with my app on line threadAudio.start()

private void startAudio(int audioId) {

    mPlayer = MediaPlayer.create(this, audioId);

    mPlayer.setOnCompletionListener(new OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
            mp.stop();
            mp.release();
            mPlayer = null;
        }
    });

    mPlayer.start();
    vSeek.setMax(mPlayer.getDuration());

    threadAudio = new Thread(thread);
    threadAudio.start();
}

public Runnable thread = new Runnable() {
    public void run() {
        try {
            while(mPlayer != null){
                int currentPosition = mPlayer.getCurrentPosition();
                Message msg = new Message();
                msg.what = currentPosition;
                handler.sendMessage(msg);
            }
            Thread.sleep(100);
        } catch (Exception e) {
        }
    }
};

private Handler handler = new Handler() {
    public void handleMessage(Message msg){
        vSeek.setProgress(msg.what);
    }
};

First, i am not able to reproduce the error on my device! Can this be device-specific?

I am using handler as per android doc suggestion to avoid accessing the Android UI toolkit from outside the UI thread…

Or maybe I have to call threadAudio.stop() somewhere between the lines?

  • 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-06-03T06:25:44+00:00Added an answer on June 3, 2026 at 6:25 am

    I think you meant to put Thread.sleep(100); inside your while(mPlayer != null){ loop? Essentially your while loop is continuously sending armies upon armies of message to your handler, which runs on the UIThread, and this is what caused ANR keyDispatchingTimedOut error: all the CPU time are either spent processing those messages OR spent on sending those messages. Not a good place to be in 😛

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

Sidebar

Related Questions

I am getting the following error from some users while performing a lightweight Core
Some users are getting an error message when trying to attach a file to
Symptom: Some users cannot successfully POST, most can successfully POST. When the error occurs,
I'm having some trouble getting personal contacts of some users I have in a
On my site wemanageloans.com, many of the users are getting the following error when
I'm getting some js errors only for some users, and only every once in
I have a rails 2.3.10 app, from some reason some of my users are
Some of our users are getting this exception sometimes (not for every contact): System.Runtime.InteropServices.COMException
I am, from only some users, getting a InvalidAuthenticityToken exception. When I examine the
I am getting this intermittent error for some visitors to my site where even

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.