这里我在预览期间为CameraPreview开发了一个相机应用程序我打开了IntentChooser Dialog用于邮件发送,但问题是当我没有选择任何选项并按下设备的后退按钮我的CameraPreview显示黑屏但在日志上有些行打印。没有任何错误发生,但预览显示黑屏。
@Override
protected void onResume()
{
try
{
super.onResume();
System.out.println("==== Actvity RESUME ====");
previewing = true;
autoFocusHandler = new Handler();
mCamera = Camera.open();
/* Instance barcode scanner */
scanner = new ImageScanner();
scanner.setConfig(0, Config.X_DENSITY, 3);
scanner.setConfig(0, Config.Y_DENSITY, 3);
mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
preview = (FrameLayout)findViewById(R.id.cameraPreview);
preview.addView(mPreview);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void onPause()
{
try
{
super.onPause();
System.out.println("==== Actvity PAUSE ====");
releaseCamera();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
@Override
protected void onDestroy()
{
// TODO Auto-generated method stub
super.onDestroy();
System.out.println("==== Actvity DESTROY ====");
releaseCamera();
//mCamera.release();
}
private void releaseCamera()
{
if (mCamera != null)
{
previewing = false;
mCamera.setPreviewCallback(null);
mCamera.release();
mCamera = null;
}
}
这里我的表面摧毁了两次。
请帮帮我, 在此先感谢。