eclipse - How to pause Android Background Runnable Thread? -


i have method throwing invocationtargetexception every single time right after onpause called. happening on line of "long totalduration = mp.getduration();" how go stopping exception?

/**  * 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 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 ");         }     }  } 

// mhandler -> mhandler handler instance //     -> mupdatetimetask runnable anonymous class  mhandler.removecallbacks( ); 

don't stop instantly, prevent next scheduled call.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -