title: Too much work on main thread Warning
body: <p>I developed a very basic camera app, so far it only contains the camera preview and a button to take a photo which is then saved. I am now wondering why I would run into a warning that my application might be doing to much work on it's main thread (it skips 35 frames). All I do so far on my UI thread can be seen in my <code>onCreate()</code>:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      fullScreencall();
  
      setContentView(R.layout.activity_capture);
  
      mCamera = getCameraInstance();
  
      // Create our Preview view and set it as the content of our activity.
      mPreview = new CameraPreview(this, mCamera);
      FrameLayout preview = (FrameLayout) findViewById(R.id.camera);
      preview.addView(mPreview, 0);
      mButtonCapture = (Button) findViewById(R.id.btnCapturePhoto);
      mButtonCapture.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              ImageSaverThread ist = new ImageSaverThread(mCamera);
              ist.start();
          }
      });
  }
  </code></pre>
  
  <p>To me, this seems not to be so much work, and I cannot find anything that I could separate into another thread. Taking a photo and saving it is already done in a thread.</p>
  
  <p>Any idea what I am missing here?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>ImageSaverThread.java</p>
  
  <pre><code>public class ImageSaverThread extends Thread {
  
      private Camera mCamera;
      public static final int MEDIA_TYPE_IMAGE = 1;
  
      public ImageSaverThread(Camera camera){
          mCamera = camera;
      }
  
      public void run(){
          PictureCallback mPicture = new PictureCallback() {
  
              @Override
              public void onPictureTaken(byte[] data, Camera camera) {
  
                  File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
                  if (pictureFile == null){
                      return;
                  }
  
                  try {
                      FileOutputStream fos = new FileOutputStream(pictureFile);
                      fos.write(data);
                      fos.flush();
                      fos.close();
                  } catch (FileNotFoundException e) {
                      Log.d("FAIL", "File not found: " + e.getMessage());
                  } catch (IOException e) {
                      Log.d("FAIL", "Error accessing file: " + e.getMessage());
                  }
              }
          };
          mCamera.takePicture(null, null, mPicture);
      }
  
      private static File getOutputMediaFile(int type){
          // To be safe, you should check that the SDCard is mounted
          // using Environment.getExternalStorageState() before doing this.
  
          File mediaStorageDir = new File(String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)));
          // This location works best if you want the created images to be shared
          // between applications and persist after your app has been uninstalled.
  
          // Create the storage directory if it does not exist
          if (! mediaStorageDir.exists()){
              if (! mediaStorageDir.mkdirs()){
                  Log.d("MyCameraApp", "failed to create directory");
                  return null;
              }
          }
          String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
          File mediaFile;
          if (type == MEDIA_TYPE_IMAGE){
              mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                      "IMG_"+ timeStamp + ".jpg");
          } else {
              return null;
          }
  
          return mediaFile;
      }
  }
  </code></pre>