I use surfaceview and camera to take pictures.
I use the method by the android website:
http://developer.android.com/reference/android/hardware/Camera.html
It told us:
Important: Call release() to release the camera for use by other applications. Applications should release the camera immediately in onPause() and re-open() it in onResume()
My code as below:
protected void onPause() {
super.onPause();
if (bfCamera != null) {
bfCamera.stopPreview();
bfCamera.release();
}
}
protected void onResume() {
super.onResume();
bfCamera.startPreview();
bfCamera.open();
}
It work before incoming phone call.
My app was shut down when my friend called me.
The picture of preview can not work.
It display all black color.
any suggestion? Thanks
You will have to re-instantiate the camera object when the onResume() method is called – and you may as well set the bfCamera = null inside the onPause() method as well. The object has probably been removed by the garbage collector.