title: Front Camera2 API GLSurfaceview
body: <p>I'm trying to access the front facing camera through the <em>Camera2 API</em> using an actual device</p>
  
  <p>the problem occurs when trying to </p>
  
  <blockquote>
    <p>cameraManager.openCamera(..,..,..)</p>
  </blockquote>
  
  <pre><code>try {
          CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraID);
              if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) {
                  throw new RuntimeException("Time out waiting to lock camera opening.");
              }
              manager.openCamera(mCameraID, mStateCallback, mBackgroundHandler);
          } catch (CameraAccessException e) {
              Log.e("mr", "OpenCamera - Camera Access Exception");
          } catch (IllegalArgumentException e) {
              Log.e("mr", "OpenCamera - Illegal Argument Exception");
          } catch (SecurityException e) {
              e.printStackTrace();
              Log.e("mr", "OpenCamera - Security Exception:");
          } catch (InterruptedException e) {
              Log.e("mr", "OpenCamera - Interrupted Exception");
          }
  </code></pre>
  
  <p>the Cameramanager says</p>
  
  <blockquote>
    <p>I/CameraManagerGlobal: Connecting to camera service</p>
  </blockquote>
  
  <p>which is coming from this <em>CameraManager.java</em> function</p>
  
  <pre><code>private void connectCameraServiceLocked() {
              // Only reconnect if necessary
              if (mCameraService != null) return;
  
              Log.i(TAG, "Connecting to camera service");
  </code></pre>
  
  <p>Then my GLSurfaceView remains <strong>blank</strong></p>
  
  <p><em>AndroidMainfest.xml</em></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;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" /&gt;
  
      &lt;uses-feature
          android:glEsVersion="0x00020000"
          android:required="true" /&gt;
  </code></pre>
  
  <p><strong>P.S:</strong></p>
  
  <ul>
  <li>It works with the back camera</li>
  <li>It works with the nexus 6 API 23 emulator</li>
  <li>Permissions are requested at runtime for Android M</li>
  <li>I'm using <em>GLSurfaceView</em> as a viewfinder</li>
  <li>The front camera was working perfectly on the same device using the normal <em>CameraAPI</em> with a <em>TextureView</em></li>
  <li>Tried to Uninstall/Reboot/Clear Cache</li>
  <li>the device I'm using is a <em>Sony Z5 premium</em></li>
  </ul>
  
  <p>I'm using this example <a href="http://maninara.blogspot.nl/2015/03/render-camera-preview-using-opengl-es.html" rel="nofollow">Render camera preview using OpenGL ES 2.0 on Android API 21 or higher</a></p>