我有,我有一個Runnable哪些更新搜索條和currentposition TextView的每100毫秒更新的TextView導致活動停止
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);
}
};
的問題是,經過一段時間後什麼媒體播放服務(5- 10秒)活動停止,我在logcat中看到的唯一錯誤就是這個。雖然刪除nowduration.setText
所有工作正常,seekbar正在更新沒有任何問題,爲什麼TextView活動停止?
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}
我的嘗試:1.使用上TextView.setText runOnUithread - 同樣的行爲2.使用一個線程,而不是處理程序 - 但我有問題回採線程,有時我需要調用Handler.removeCallBacks
,但我知道停止線程是一個非常糟糕的操作,這就是爲什麼Thread.stop(已折舊)。
你使用線程以外的處理程序?你可以使用'Handler.removeCallBacks'。我認爲你誤解了處理程序的使用http://developer.android.com/reference/android/os/Handler.html併發布完整的棧跟蹤 – Raghunandan