I have a mediaplayer service in which i have a Runnable which updates the seekbar and currentposition TextView every 100 milliseconds
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
long totalDuration = mediaPlayer.getDuration();
long currentDuration = mediaPlayer.getCurrentPosition();
seekBar.setProgress(progress);
nowduration.setText("" + utils.milliSecondsToTimer(currentDuration));
totalduration.setText(""+utils.milliSecondsToTimer(totalDuration));
// Running this thread after 100 milliseconds
mHandler.postDelayed(this, 100);
}
};
The problem is, what after some time (5-10 seconds) Activity stops, and the only error I see in logcat is this. While removing nowduration.setText
all works fine, seekbar is updating without any problem, why with TextView activity stops?
04-10 10:22:40.610 288-813/system_process I/ActivityManager﹕ Process com.package.appname (pid 3734) has died.
04-10 10:22:40.610 288-3633/system_process I/WindowManager﹕ WIN DEATH: Window{424b5708 com.package.appname/com.package.appname.MainActivity paused=false}
What I tried: 1. using runOnUithread on TextView.setText - same behaviour 2. Using a Thread instead of Handler - but I have problem stoping the Thread, sometimes I need to call Handler.removeCallBacks
, but as I know stoping a thread is a very bad action, this is why Thread.stop( was depreciated).