title: Receiving CameraAccessException: CAMERA_ERROR (3) on CaptureSession.setRepeatingRequest()
body: <p>I have the Following code running from the onCreate() method. outside of this code is just a lot of object declarations and instantiations for the callbacks.</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      thisAct = this;
      display = (TextureView)findViewById(R.id.display);
      display.setSurfaceTextureListener(surfaceTextureListener);
  
      db = openOrCreateDatabase("MyDatabase", Context.MODE_PRIVATE, null);
      db.execSQL("CREATE TABLE IF NOT EXISTS Photos (ID INTEGER, location TEXT, size INTEGER)");
      db.execSQL("CREATE TABLE IF NOT EXISTS Tags (ID INTEGER, tag TEXT)");
  
      camMan = this.getSystemService(CameraManager.class);
  
      new Thread(new Runnable(){
          @Override
          public void run() {
              try {
                  String cm = camMan.getCameraIdList()[0];
  
                  if ( ContextCompat.checkSelfPermission(thisAct, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED ) {
                      ActivityCompat.requestPermissions((Activity)thisAct, new String[] { Manifest.permission.CAMERA }, CAMERA_REQUEST);
                  }
                  camMan.openCamera(cm, CDstateCallback, handle);
  
                  while(texture == null){
                      try{
                          Thread.sleep(100);
                          Log.v("DEBUG!!!!!!!!", "Thread sleeping b/c texture is null");
                      } catch(Exception e){
                          e.printStackTrace();
                      }
                  }
  
  //              texture.setDefaultBufferSize(325,325);
                  Surface s = new Surface(texture);
                  surfaceList.add(s);
  
                  while(cameraDevice == null){
                      try{
                          Thread.sleep(100);
                          Log.v("DEBUG!!!!!!!!", "Thread sleeping b/c cameraDevice is null");
                      } catch(Exception e){
                          e.printStackTrace();
                      }
                  }
  
                 cameraDevice.createCaptureSession(surfaceList, CCSstateCallback, handle);
  
                 while(capSess == null){
                      try{
                          Thread.sleep(100);
                          Log.v("DEBUG!!!!!!!!", "Thread sleeping b/c capSess is null");
                      } catch(Exception e){
                          e.printStackTrace();
                      }
                  }
  
                  capSess.prepare(surfaceList.get(0));
  
                  capReq = cameraDevice.createCaptureRequest(cameraDevice.TEMPLATE_PREVIEW);
                  capReq.addTarget(surfaceList.get(0));
                  capSess.setRepeatingRequest(capReq.build(), CCSlistener, handle);
  
              } catch (CameraAccessException e) {
                  e.printStackTrace();
              }
          }
      }).start();
  }
  </code></pre>
  
  <p>When this line executes, I receive the following error in the console:</p>
  
  <pre><code>capSess.setRepeatingRequest(capReq.build(), CCSlistener, handle);
  </code></pre>
  
  <p>.</p>
  
  <pre><code>android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): submitRequestList:257: Camera 0:  Got error Invalid argument (-22) after trying to set streaming request
  </code></pre>
  
  <p>After doing some searching online, it seems that this is referring to the <strong>"ERROR_CAMERA_DISABLED"</strong> code, <strong><em>indicating that the camera device could not be opened due to a device policy.</em></strong></p>
  
  <p>This initially made me think to look straight to the permissions, but as seen in the lines:</p>
  
  <pre><code>if ( ContextCompat.checkSelfPermission(thisAct, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED ) {
                          ActivityCompat.requestPermissions((Activity)thisAct, new String[] { Manifest.permission.CAMERA }, CAMERA_REQUEST);
                      }
  </code></pre>
  
  <p>,</p>
  
  <p>I check for permissions and prompt the user for them if the app doesn't already have them. I've also checked in my app settings in the manifest file, and on the device to confirm that I do in fact have the camera hardware permissions.
  Can any one help me solve this issue?</p>