title: openCamera in AsyncTask returns "IllegalArgumentException"
body: <p>I am trying to create an <em>AsyncTask</em> which will take pictures in background, but I am receiving </p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Handler argument is null, but no looper exists in the calling thread</p>
  </blockquote>
  
  <p>In the <strong>doInBackgroung</strong> method I've got:</p>
  
  <pre><code>    @Override
  protected String doInBackground(Object[] objects) {
      startBackgroundThread();
      openCamera();
      takePicture();
      return "Executed";
  }
  </code></pre>
  
  <p>and then in the <strong>openCamera</strong> method:</p>
  
  <pre><code>private void openCamera() {
      CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
      try{
          cameraId = manager.getCameraIdList()[1];
          CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
          StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
          assert map != null;
          imageDimension = map.getOutputSizes(SurfaceTexture.class)[0];
  
          manager.openCamera(cameraId,stateCallback,null); //It is breaking here
  
      } catch (CameraAccessException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Any suggestion how can I solve this ?</p>
  
  <p><strong>Edit:</strong> Forgot to mention that the application works fine when I am using just a normal Activity, but now I want to move that camera code into and AsyncTask, so it runs in background.</p>