0

onPause が呼び出された直後に毎回 InvocationTargetException をスローするメソッドがあります。「long totalDuration = mp.getDuration();」の行で発生しています。この例外を停止するにはどうすればよいですか?

/**
 * Background Runnable thread
 * */
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);
   }
};


@Override
public void onPause(){
    super.onPause();
    if(mp != null){
        try{
        mp.stop();//mp=mediaplayer
        mp.release();
        } catch(Exception e){
            Log.e(TAG, "Error in onPause()\n ");
        }
    }

}
4

2 に答える 2