Agrego un la forma de realizarlo, primeramente agrega los permisos dentro de AndroidManifest.xml : <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> Creamos la clase `CameraView` que es basada en tu código original: import android.content.Context; import android.hardware.Camera; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import java.io.IOException; public class CameraView extends SurfaceView implements SurfaceHolder.Callback { private SurfaceHolder mHolder; private Camera mCamera; public CameraView(Context context, Camera camera){ super(context); mCamera = camera; mCamera.setDisplayOrientation(90); mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_NORMAL); } @Override public void surfaceCreated(SurfaceHolder surfaceHolder) { try { mCamera.setPreviewDisplay(mHolder); mCamera.startPreview(); } catch (IOException e) { Log.d("ERROR", "Camera error on surfaceCreater" + e.getMessage()); } } @Override public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) { if(mHolder.getSurface() == null) return; try{ mCamera.stopPreview(); } catch (Exception e){ Log.e("ERROR", e.getMessage()); } try{ mCamera.setPreviewDisplay(mHolder); mCamera.startPreview(); } catch (IOException e) { Log.d("ERROR", "Camera error on surfaceChanged " + e.getMessage()); } } @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { mCamera.stopPreview(); mCamera.release(); } } Para cargar la vista creamos una actividad, en la cual primeramente definimos el layout, `activity_camera.xml`: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <FrameLayout android:id="@+id/camera_view" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imgClose" android:layout_gravity="right|top" android:background="@android:drawable/ic_menu_close_clear_cancel" android:padding="20dp"/> </FrameLayout> Definimos nuestra actividad, la cual debe estar registrada dentro de tu `AndroidManifest.xml` : import android.hardware.Camera; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageButton; public class CameraActivity extends AppCompatActivity { private static final String TAG = "CameraActivity"; private Camera mCamera = null; private CameraView mCameraView = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); try{ mCamera = Camera.open(); } catch (Exception e){ Log.d("ERROR", "Failed to get camera: " + e.getMessage()); } if(mCamera != null) { mCameraView = new CameraView(this, mCamera); FrameLayout camera_view = (FrameLayout)findViewById(R.id.camera_view); camera_view.addView(mCameraView);//agrega la vista CameraView() } //boton para cerrar la aplicación. ImageButton imgClose = (ImageButton)findViewById(R.id.imgClose); imgClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //Cierra la actividad. finish(); } }); } } Al ejecutar nuestra aplicación, se abrirá la camara : [![introducir la descripción de la imagen aquí][1]][1] Finalmente te comento que este ejemplo usa la clase [Camera][2] la cual es obsoleta desde la API 21, ahora se recomienda el uso de la clase **[Camera2][3]** [1]: https://i.sstatic.net/sErO2.png [2]: http://developer.android.com/intl/es/reference/android/hardware/Camera.html [3]: http://developer.android.com/intl/es/reference/android/hardware/camera2/package-summary.html