Android Camera is being used after Camera.release() was called
程序员文章站
2022-06-15 13:53:35
...
今天编了一个摄像头程序,由主界面和摄像头界面组成,摄像头界面里具有:采集图片,识别图片,然后显示图片。采集和显示在一个线程里(ImageThread),调用一个识别线程池,线程池里有并行线程(FindBrightColor)。每次退出摄像头界面,eclipse提示:“Camera is being used after Camera.release() was called”,程序死了。
有问题的代码:
public void stop() {
if (mThread != null) {
GlobalThreadPool.shutdown();
mStopped = true;
mThread = null;
}
}
改写后的:
public void stop() {
if (mThread != null) {
////在shundown之前,必须移走线程
for(int i=0;i<8;i++){
GlobalThreadPool.remove(myThread_Find_Bright_Color[i]);
}
GlobalThreadPool.shutdown();
mStopped = true;
mThread = null;
}
}
问题jiej解决了。