我正在开发一个音乐应用程序,其中正在使用一个Seekbar。我有一个方法可以处理seekbar的性能,而且效果很好。但如果搜索条是在行动有内存泄漏和日志猫节目如Android TextView内存泄漏
GC_CONCURRENT freed 1692K, 34% free 10759K, paused 3ms+8ms
这个不断到来时,搜索条进展
我发现,这个问题是由于的TextView的更新用,动态地显示当前歌曲的持续时间。
我该如何解决这个问题。请帮我这个问题
我的功能是
public void seekbarProgress(){
handler.postDelayed(new Runnable() {
@Override
public void run() {
//current position of the play back
currPos = harmonyService.player.getCurrentPosition();
if(isPaused){
//if paused then stay in the current position
seekBar.setProgress(currPos);
//exiting from method... player paused, no need to update the seekbar
return;
}
//checking if player is in playing mode
if(harmonyService.player.isPlaying()){
//settting the seekbar to current positin
seekBar.setProgress(currPos);
//updating the cuurent playback time
currTime.setText(getActualDuration(""+currPos));
handler.removeCallbacks(this);
//callback the method again, wich will execute aftr 500mS
handler.postDelayed(this, 500);
}
//if not playing...
else{
//reset the seekbar
seekBar.setProgress(0);
//reset current position value
currPos = 0;
//setting the current time as 0
currTime.setText(getActualDuration(""+currPos));
Log.e("seekbarProgress()", "EXITING");
//exiting from the method
return;
}
}
}, 500);
}
为什么要用每个搜索栏进度更新曲目的长度?您可以在MediaPlayer准备好之后更新一次。 – Rotem
我想在一个文本视图中更新当前搜索时间,还有一个文本视图用于歌曲的整个持续时间,此文本视图用于正在播放的歌曲的播放时间。 – AndEngine
您多久更换一次seekbar进度?如果在文本中不显示毫秒,则可以根据搜索栏创建一个每秒更新TextView的线程。 – Rotem