Reputation: 4958
Im trying this tutorial: http://www.devx.com/wireless/Article/42482/1954 but there seems to be a problem with the line that says:
catch (Throwable ){ }
it's spitting an error:
Syntax error on token "Throwable", VariableDeclaratorId expected after this token
The code:
package com.ARtest;
import android.content.Context;
import android.graphics.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class CustomCameraView extends SurfaceView
{
Camera camera;
SurfaceHolder previewHolder;
SurfaceHolder.Callback surfaceHolderListener = new SurfaceHolder.Callback() {
public void surfaceCreated(SurfaceHolder holder) {
camera=Camera.open();
try {
camera.setPreviewDisplay(previewHolder);
}
catch (Throwable ){ }
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height)
{
Parameters params = camera.getParameters();
params.setPreviewSize(w, h);
params.setPictureFormat(PixelFormat.JPEG);
camera.setParameters(params);
camera.startPreview();
}
public void surfaceDestroyed(SurfaceHolder arg0)
{
camera.stopPreview();
camera.release();
}
};
//constructor
public CustomCameraView(Context ctx)
{
super(ctx);
previewHolder = this.getHolder();
previewHolder.setType
(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
previewHolder.addCallback(surfaceHolderListener);
}
};
Upvotes: 1
Views: 271
Reputation: 254
Throwable should have a name after, since it is an object. Just change "Throwable" to something like "Throwable e." VariableDeclaratorId means an object is unnamed, just like how you wouldn't instantiate a String as
private String = "this will not work";
To your second question, classes don't require ;'s at the end of them. Typically if there is a closing bracket, you don't need a ; after it.
Tough one to fix! You probably pasted this into eclipse, and it automatically imported graphics.camera. Change that import to hardware.camera, and try it then. Also, change
params.setPreviewSize(w, h);
to
params.setPreviewSize(width, height);
Also add the import
import android.hardware.Camera.Parameters;
Upvotes: 2