i had this working last night, and have changed the xml layout a bit, which has caused the preview just to freeze when app starts. Only major thing thats changed is ive changed it from LinearLayout to a Relative one
the logcat is huge, this is a snippet from when i think the app starts
E/SecCamera( 2191): initCamera: m_cam_fd(35), m_jpeg_fd(0)
I/SecCamera( 2191): Name of input channel[0] is CE147
E/SecCamera( 2191): initCamera: m_cam_fd2(39)
I/SecCamera( 2191): Name of input channel[0] is CE147
D/CameraHardwareSec( 2191): frame rate:30, mPreviewFrameRateMicrosec:33333
E/SecCamera( 2191): SetRotate(angle(0))
E/SecCamera( 2191): setRecordingSize(width(640), height(480))
I/ShotCommon( 2191): Picture width(2560), height(1920)
I/ShotSingle( 2191): ShotSingle created: pid=2191
D/CameraService( 2191): Client::Client X (pid 12588)
D/CameraService( 2191): CameraService::connect X
D/CameraService( 2191): setPreviewDisplay(0x501a8) (pid 12588)
D/CameraService( 2191): getParameters(AppShutterSound=0;anti-shake=0;antibanding=auto;antibanding-values=auto,50hz,60hz,off;beauty-shot=0;blur=0;brightness=4;camera-id=1;chk_dataline=0;contrast=2;digi-zoom=0;effect=none;effect-values=none,mono,negative,sepia;flash-mode=off;flash-mode-values=off;focus-mode=auto;focus-mode-values=auto,macro;iso=auto;jpeg-quality=100;jpeg-thumbnail-height=192;jpeg-thumbnail-quality=100;jpeg-thumbnail-size-values=160x120;jpeg-thumbnail-width=256;metering=center;picture-format=jpeg;picture-format-values=jpeg;picture-size=2560x1920;picture-size-values=2560x1920,2048x1536,1600x1200,640x480,2560x1536,2048x1232,1600x960,800x480;preview-format=yuv420sp;preview-format-values=yuv420sp;preview-frame-rate=30;preview-frame-rate-values=15,30;preview-size=640x480;preview-size-values=640x480,800x480;rotation=0;saturation=2;scene-mode=auto;scene-mode-values=auto,portrait,landscape,night,beach,snow,sunset,fireworks,sports,party,candlelight;sharpness=2;slow_ae=off;smart-auto=0;video_recording_gamma=off;vintagemode=off;
D/CameraService( 2191): setParameters(anti-shake=0;picture-size-values=2560x1920,2048x1536,1600x1200,640x480,2560x1536,2048x1232,1600x960,800x480;AppShutterSound=0;antibanding=auto;blur=0;digi-zoom=0;metering=center;sharpness=2;contrast=2;brightness=4;whitebalance=auto;jpeg-thumbnail-height=192;scene-mode=auto;jpeg-quality=100;preview-format-values=yuv420sp;rotation=0;jpeg-thumbnail-quality=100;focus-mode=auto;beauty-shot=0;preview-format=yuv420sp;vintagemode=off;preview-size=800x404;iso=auto;slow_ae=off;picture-format-values=jpeg;camera-id=1;flash-mode-values=off;preview-frame-rate-values=15,30;chk_dataline=0;preview-frame-rate=30;flash-mode=off;effect-values=none,mono,negative,sepia;focus-mode-values=auto,macro;picture-size=2560x1920;effect=none;saturation=2;jpeg-thumbnail-width=256;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;scene-mode-values=auto,portrait,landscape,night,beach,snow,sunset,fireworks,sports,party,candlelight;picture-format=jpeg;vtmode=0;jpeg-thumbnail-size-values=160x120;wdr=0;smart
D/CameraHardwareSec( 2191): frame rate:30, mPreviewFrameRateMicrosec:33333
E/SecCamera( 2191): SetRotate(angle(0))
E/SecCamera( 2191): setRecordingSize(width(800), height(404))
D/CameraService( 2191): startPreview (pid 12588)
D/CameraService( 2191): startCameraMode(0) (pid 12588)
D/CameraService( 2191): startPreviewMode (pid 12588)
E/CameraHardwareSec( 2191): startPreview()
E/SecCamera( 2191): stopPreview()
E/SecCamera( 2191): stopPreview: m_flag_camera_start is zero
E/SecCamera( 2191): startPreview()
D/SecCamera( 2191): passed fmt = 825382478 found pixel format[9]: YUV 4:2:0 planar, Y/CrCb
E/SecCamera( 2191): startPreview()m_preview_width: 800 m_preview_height: 404 m_angle: 0
This is the code that like i said was working fine, so i dont think this is the problem
public class QuickRecord extends Activity {
private SurfaceView preview=null;
private SurfaceHolder previewHolder=null;
private Camera camera=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
preview = (SurfaceView) findViewById(R.id.cameraPreview);
previewHolder = preview.getHolder();
previewHolder.addCallback(surfaceCallback);
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
SurfaceHolder.Callback surfaceCallback=new SurfaceHolder.Callback() {
public void surfaceCreated (SurfaceHolder holder) {
camera = Camera.open();
try {
camera.setPreviewDisplay(previewHolder);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void surfaceChanged (SurfaceHolder holder, int format, int width, int height) {
Camera.Parameters parameters = camera.getParameters();
parameters.setPreviewSize(width, height);
camera.setParameters(parameters);
camera.startPreview();
}
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera.release();
camera=null;
}
};
}
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<SurfaceView
android:id="@+id/cameraPreview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<!-- android:layout_toLeftOf="@+id/button01" -->
</SurfaceView>
<Button
android:layout_width="100px"
android:layout_height="wrap_content"
android:id="@+id/button01"
android:text="Record"
android:layout_alignParentRight="true"
android:layout_above="@+id/button02"
/>
<Button
android:layout_width="100px"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="@+id/button02"
android:text="Stop"
android:layout_alignParentRight="true"
/>
<Button
android:layout_width="100px"
android:layout_height="wrap_content"
android:id="@+id/button03"
android:text="Play"
android:layout_alignParentRight="true"
android:layout_below="@+id/button02"
/>
</RelativeLayout>