Code example for SurfaceHolder

Methods: addCallback, setKeepScreenOn, setType

0
         
        super(context);
         
        // setup the surface holder 
        _surfaceHolder = getHolder();
        _surfaceHolder.setKeepScreenOn(true);
        _surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
         
        // register as callback so we get notified when the underlying surface is created, changed, or destroyed (activity gets paused) 
        _surfaceHolder.addCallback(this);
    } 
     
    /** 
     * This is called after the surface is first created. Acquires the camera and tells it where to draw. 
     */ 
    public void surfaceCreated(final SurfaceHolder holder) {
         
//    	Log.d(PhotoCompassApplication.LOG_TAG, "CameraView: surfaceCreated"); 
         
        _camera = Camera.open();
        try {