title: camera2 android camara callback camera device is null
body: <p>So I'm using the camera2 api and when I open the camera:</p>
  
  <pre><code>          private void StartUpCam() 
        {
            CameraManager CM = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
            if(camId.compareTo("")!=0)
            {
                //Log.e("camera", "started");
                try{
                    Log.e("Start up Cam and camId:", camId);
                    CM.openCamera(camId, CDcallback, null);
                }
                catch(CameraAccessException e)
                {
                    Log.e("come with me", "if you want to live");
                    e.printStackTrace();
                }
            }
        }
  </code></pre>
  
  <p>As you can see I make sure the parameters needed to open the camera all check out and they do. Anyways so when the callback is hit:</p>
  
  <pre><code>           private CameraDevice CD;
        private CameraDevice.StateCallback CDcallback
          = new CameraDevice.StateCallback() {
  
              @Override
              public void onOpened(CameraDevice camera) {
                  //Log.e("onOpened", "here");
                  CD = camera;
                  if(CD == null)
                      Log.e("onOpened", "CD is null");
                  createCamPreviewSession();
              }
  
              @Override
              public void onError(CameraDevice camera, int error) {
                  camera.close();
                  CD = null;
              }
  
              @Override
              public void onDisconnected(CameraDevice camera) {
                  camera.close();
                  CD = null;
              }
          };
  </code></pre>
  
  <p>The Camera Device from the onOpened method always is null. I have no idea why this is happening. Any ideas?</p>