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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:05:38+00:00 2026-06-15T21:05:38+00:00

My music player application seems to have a problem. When I exit from it,

  • 0

My music player application seems to have a problem. When I exit from it, it pops out force close warning. This is the part of the code where I think might be the cause of the problem after debugging it:

private Runnable mUpdateTimeTask = new Runnable() {
           public void run() {
               long totalDuration = mp.getDuration();
               long currentDuration = mp.getCurrentPosition();

               // Displaying Total Duration time
               songTotalDurationLabel.setText(""+utils.milliSecondsToTimer(totalDuration));
               // Displaying time completed playing
               songCurrentDurationLabel.setText(""+utils.milliSecondsToTimer(currentDuration));

               // Updating progress bar
               int progress = (int)(utils.getProgressPercentage(currentDuration, totalDuration));
               //Log.d("Progress", ""+progress);
               songProgressBar.setProgress(progress);

               // Running this thread after 100 milliseconds
               mHandler.postDelayed(this, 100);
           }
        };

And here’s the logcat:

12-13 13:26:01.700: E/AndroidRuntime(31838): FATAL EXCEPTION: main
12-13 13:26:01.700: E/AndroidRuntime(31838): java.lang.IllegalStateException
12-13 13:26:01.700: E/AndroidRuntime(31838):    at android.media.MediaPlayer.getDuration(Native Method)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at com.example.musicshare.AndroidBuildingMusicPlayerActivity$1.run(AndroidBuildingMusicPlayerActivity.java:341)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at android.os.Handler.handleCallback(Handler.java:587)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at android.os.Handler.dispatchMessage(Handler.java:92)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at android.os.Looper.loop(Looper.java:123)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at android.app.ActivityThread.main(ActivityThread.java:3691)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at java.lang.reflect.Method.invokeNative(Native Method)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at java.lang.reflect.Method.invoke(Method.java:507)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
12-13 13:26:01.700: E/AndroidRuntime(31838):    at dalvik.system.NativeStart.main(Native Method)

The problem is with mp.getDuration I think but I dont know how to fix it.

  • 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-15T21:05:39+00:00Added an answer on June 15, 2026 at 9:05 pm

    Looks like your runnable task still runs at the back even after you exit. So my gues is that you could have forgot to call the removeCallbacks().

    My suggestion is to add the below line in your onBackPressed() or at the place where you exit the app,

     mHandler.removeCallbacks(mUpdateTimeTask);
    

    Make sure you declare your Runnable mUpdateTimeTask globally so that it is available through out your code.

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

Sidebar

Related Questions

In my music player application, I have got a TextView with Artist, Title and
I'm writing a music player application using WPF (C#). As part of its functionality,
I'm embedding a flash music player from Soundclick into my music website. I have
I have a master page and inside : a music player. <object type=application/x-shockwave-flash data=http://flash-mp3-player.net/medias/player_mp3_maxi.swf
In my application I have a music player, which plays music with a length
I have a problem in my iframe facebook application, is a music app where
Before open my application I played some of the music from default music player.
I have the music player application in which I have 90 songs total. I
i have created an application its a music player with just a simple layout
I want to write an application that monitors a music player. In my app

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.