title: Basic camera in app
body: <p>I am just trying to activate the camera in my app I have done the following and kept it as simple as possible. </p>
  
  <p><strong>AndroidManifest file</strong> </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.CAMERA"/&gt;
  &lt;uses-feature android:name="android.hardware.camera" /&gt;
  &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt;
  ...
      &lt;activity
          android:name=".CameraAct"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p><strong>CameraAct.class</strong></p>
  
  <pre><code>   public class CameraAct extends AppCompatActivity {
  
         public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_camera);
  
          // do we have a camera?
          if (!getPackageManager()
                  .hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
              Toast.makeText(this, "No camera on this device", Toast.LENGTH_LONG)
                      .show();
          } else {
              cameraId = findFrontFacingCamera();
              if (cameraId &lt; 0) {
                  Toast.makeText(this, "No front facing camera found.",
                          Toast.LENGTH_LONG).show();
              } else {
                  camera = Camera.open(cameraId);
              }
            }
         }
  
         private int findFrontFacingCamera() {
            int cameraId = -1;
            // Search for the front facing camera
            int numberOfCameras = Camera.getNumberOfCameras();
            for (int i = 0; i &lt; numberOfCameras; i++) {
               CameraInfo info = new CameraInfo();
               Camera.getCameraInfo(i, info);
               if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
                  Log.d(DEBUG_TAG, "Camera found");
                  cameraId = i;
                  break;
              }
            }
          return cameraId;
      }
  </code></pre>
  
  <p><strong>activity_camera.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent" android:layout_height="match_parent"&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The activity opens and on the log the I see the <code>debug_tag</code>: Camera found in logcat however I dont see the camera on the screen. This is what I see when the activity launches:
  <a href="https://i.stack.imgur.com/JKv2e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JKv2e.png" alt="enter image description here"></a></p>