title: recreating camera object after error 100 (camera server died)
body: <p>I have classic android app with camera preview (common implem that can be found in many tutorials [marakana etc.]) that is supposed to take picture in a given time interval. Threading and killing threads is done, errors such <code>"method called after release"</code> are handled. But sometimes the well-known error <code>100</code> occurs. I accepted the fact that it happens and tried to handle it too. I implemented <code>ErrorCallback</code> and its <code>onError</code> method where the current camera object is released and instantiated a new one as written in official documentation. </p>
  
  <p>But (with no surprise) it is not enough. New camera is maybe wrongly allocated because an message <code>"CameraDemo has been exited unexpectedly"</code> appears now.
  I've read many docs and examples in hope, that a proper proceeding will be somewhere explained but no one has such problem apparently. So I would like to ask what else should I do beside releasing and creating new camera? Here is the code:</p>
  
  <pre><code>ErrorCallback CEC = new ErrorCallback()
  {
      public void onError(int error, Camera camera)
      {
          Log.d("CameraDemo", "camera error detected");
          if(error == Camera.CAMERA_ERROR_SERVER_DIED)
          {
              Log.d("CameraDemo", "attempting to reinstantiate new camera");
              camera.stopPreview();
              camera.setPreviewCallback(null);
              camera.release(); //written in documentation...
              camera = null;              
              camera = Camera.open();
  
          }
      }
  };
  </code></pre>
  
  <p>Shortly - if I release and recreate camera in <code>onError</code> callback then <code>RuntimeException</code> Method called after release (takePicture) is raised. So should I somehow assign the surface holder to camera again or recreate the surface holder too?</p>
  
  <p>It would be enough to direct me e.g. to some forums, where it is described or solved, etc. Thanks for any help. </p>