Code example for Camera

Methods: setPreviewTexturestartPreview

0
    @Override 
    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
        mCamera = Camera.open();
 
        try { 
            mCamera.setPreviewTexture(surface);
        } catch (IOException t) {
            android.util.Log.e("TextureView", "Cannot set preview texture target!", t);
        } 
 
        mCamera.startPreview();
    } 
 
    @Override 
    public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
        // Ignored, the Camera does all the work for us 
    } 
 
    @Override 
    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
Contextual code suggestions in your IDE  Get Codota for Java