我有一些拍照的代码在Android 2.1和2.2中有效.但这些代码在Android 2.3上爆发.花了一些时间来解决这个徒劳的问题后,我想在这里寻求帮助.
我拍照的代码流是这样的:
创建一个类Camlayer扩展了SurfaceView
public class CamLayer extends SurfaceView implements SurfaceHolder.Callback {
private void init(Context context){
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera = Camera.open();
}
public CamLayer(Context context) {
super(context);
init(context);
}
public CamLayer(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Log.i(TAG+".surfaceChanged", "being called!");
Log.i(TAG+".surfaceChanged", "w="+w);
Log.i(TAG+".surfaceChanged", "h="+h);
if (isPreviewRunning) …Run Code Online (Sandbox Code Playgroud)