Hello,
I'm building this app, which requires a Camera, but it is not working, it doesn't show anything except the design, here's teh code:
Camera c = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.qrreaderscreen);
SurfaceView v = (SurfaceView) findViewById(R.id.v);
SurfaceHolder surface_holder = null;
v = new SurfaceView(getApplicationContext());
if (surface_holder == null) {
surface_holder = v.getHolder();
}
//surface_holder.addCallback((Callback) this);
//surface_holder.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
try {
c = Camera.open();
c.setPreviewDisplay(surface_holder);
c.startPreview();
}
catch (Exception e){
System.out.println("gasgasga");
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
c.stopPreview();
c.release();
c = null;
}
public void surfaceCreated(SurfaceHolder holder) {
c = Camera.open();
try {
c.setPreviewDisplay(holder);
} catch (IOException exception) {
c.release();
c = null;
}
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
c.startPreview();
}
Any help would be appreciated.