I have a strange issue in my camera app when tested with galaxy nexus..It simply crash when try to start the camera activity..But it works fine with almost all other devices..
These are my functions…..
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
try {
camera = Camera.open();
camera.setPreviewDisplay(holder);
Camera.Parameters parameters = camera.getParameters();
if (Integer.parseInt(Build.VERSION.SDK) >= 8)
setDisplayOrientation(camera, 90);
else
parameters.set("orientation", "portrait");
parameters.setPictureFormat(PixelFormat.JPEG);
camera.setParameters(parameters);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
if(previewing){
camera.stopPreview();
previewing = false;
}
if (camera != null){
try {
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
previewing = true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Can anyone help
me ?
finally i got the answer..Nexus has both front and back end cameras.So the problem was the code which used to open the camera(need to set the camera id for the front end camera) and also we need to set the appropriate preview size..Here is the modified code..