2
對不起,我可憐的英語:)。 在我的APP中,有一個VideoView
可以播放視頻(m3u8)。 在此VideoView
活動中,我使用Thread
和ExecutorService(newCachedThreadPool)
來獲取播放網址和其他信息。 時,我想回到過去的活動,我做這樣的事情:我怎麼能釋放活動完成線程?
@Override
public void onDestroy() {
super.onDestroy();
if (videoView != null) {
videoView.stopPlayback();
videoView = null;
}
if (executor != null) {
executor.shutdownNow();
executor = null;
}
}
這裏是Runnable的
private Runnable changeSeekBar = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
while (seekBarAutoFlag) {
if (null != videoPlay.this.videoView&& videoPlay.this.videoView.isPlaying()) {
video_seekBar.setProgress((int) videoView.getCurrentPosition());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
和excutor這樣的:
executor.execute(changeSeekBar);
這裏是錯誤信息 enter image description here
停止線程調用這個'新主題(可運行).interrupt();' – Bharatesh
由於不知道如何使用Java的一般-threads。 您有涉及寄存器的錯誤信息。這意味着您的硬件或其他軟件或共享庫存在問題。這是不可能的,因爲它對中國 – iantonuk
謝謝〜,標題(發送給MIUI)意味着發送一條錯誤消息給MIUI(一家公司),我試試這個,這是工作。但有一些錯誤,所以我嘗試使用WearHandler.Thank很多! :) – buruoyanyang