运行时错误,但逐步调试工作正常
我写了一个android程序来拍照而不预览。当我一步步调试时,我的程序运行得很好。但是,当我在执行模式下运行它时,程序无法按预期工作。没有保存图片,程序无法完成。此外,除非重新启动手机,否则我无法在其他 Android 应用程序(例如相机、摄像机)中使用我的相机。有人对这个问题有什么想法吗?拍照的代码和记录的错误如下:
拍照的代码:
SurfaceView view = new SurfaceView(this);
mCamera = Camera.open();
Camera.Parameters p = mCamera.getParameters();
p.setPictureFormat(PixelFormat.JPEG);
mCamera.setParameters(p);
try {
mCamera.setPreviewDisplay(view.getHolder());
mCamera.startPreview();
mCamera.takePicture(null, null, mPictureCallback);
mCamera.stopPreview();
mCamera.unlock();
mCamera.release();
} catch (Exception e) {
mCamera.stopPreview();
mCamera.release();
e.printStackTrace();
}
回调函数
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] imageData, Camera c) {
if (imageData != null) {
StoreByteImage(mContext, imageData, 50,
"ImageName");
finish();
}
}
};
}
logcat 报告的错误:
ERROR/Adreno200-ES20(130): rb verson is SBA #24
ERROR/mm-camera(130): prepare snapshot: Aec not settle
ERROR/CameraService(130): mHardware->setOverlay() failed with status -2147483648
ERROR/mm-camera(130): camera_issue_command: get_picture error (Connection timed out): length 36, status 0 FD: 20 1
ERROR/QualcommCameraHardware3D(130): getPicture: CAMERA_OPS_GET_PICTURE ioctl failed!
ERROR/NotificationService(292): adbEnabled = false
ERROR/NotificationService(292): adbEnabled = true
大家能给点建议吗?先感谢您
I wrote an android program to take a picture without preview. My programs works fine when I debug it step by step. However, when I run it in execution mode, the program doesn't work as expected. No picture is saved and the program can not finish. In addition, I can not use my camera in other android applications(e.g. Camera, Camcorder) unless I restart my phone. Anybody have any ideas about this problem? The code for taking pictures and the logged errors is as follows:
Code for taking pictures:
SurfaceView view = new SurfaceView(this);
mCamera = Camera.open();
Camera.Parameters p = mCamera.getParameters();
p.setPictureFormat(PixelFormat.JPEG);
mCamera.setParameters(p);
try {
mCamera.setPreviewDisplay(view.getHolder());
mCamera.startPreview();
mCamera.takePicture(null, null, mPictureCallback);
mCamera.stopPreview();
mCamera.unlock();
mCamera.release();
} catch (Exception e) {
mCamera.stopPreview();
mCamera.release();
e.printStackTrace();
}
The callback function
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] imageData, Camera c) {
if (imageData != null) {
StoreByteImage(mContext, imageData, 50,
"ImageName");
finish();
}
}
};
}
The reported errors by logcat:
ERROR/Adreno200-ES20(130): rb verson is SBA #24
ERROR/mm-camera(130): prepare snapshot: Aec not settle
ERROR/CameraService(130): mHardware->setOverlay() failed with status -2147483648
ERROR/mm-camera(130): camera_issue_command: get_picture error (Connection timed out): length 36, status 0 FD: 20 1
ERROR/QualcommCameraHardware3D(130): getPicture: CAMERA_OPS_GET_PICTURE ioctl failed!
ERROR/NotificationService(292): adbEnabled = false
ERROR/NotificationService(292): adbEnabled = true
Can anybody give any suggestion? Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对你有用吗?
does this work for you?