title: Camera not working when lock screen and return
body: <p><br>
  i am working on a app which opens flash to preview image data and turns off the flash when done. </p>
  
  <pre><code>public void openFlash() {
      try {
          flash =false;
          previewing=false;
          finger_placed=false;
  
          Log.d("", "openFlash");
          if(camera==null){
              camera = application.getCamera();
              preview = Dashboard.preview;
              previewHolder = Dashboard.previewHolder;
  
          }
          Camera.Parameters parameters = camera.getParameters();
          parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
  
          camera.setParameters(parameters);
          camera.setPreviewDisplay(previewHolder);
          camera.setPreviewCallback(previewCallback);
          camera.startPreview();
      } catch (Throwable t) {
          Log.e("PreviewDemo-surfaceCallback", "Exception in setPreviewDisplay()", t);
      }
  }
  
  public void stopPreview() {
  
      try{
          Log.d("", "stopPreview");
          Camera.Parameters parameters = camera.getParameters();
          parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
          camera.setParameters(parameters);
          camera.stopPreview();
          previewing=false;
      }catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>every thing works fine untill i lock the screen.WHen i unlock the screen and use app. openFlash doesnot works. and gives error as below </p>
  
  <pre><code>06-20 12:13:25.725: E/AndroidRuntime(29033): FATAL EXCEPTION: main
  
  06-20 12:13:25.725: E/AndroidRuntime(29033): java.lang.RuntimeException: Method called after release()
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at android.hardware.Camera.setHasPreviewCallback(Native Method)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at android.hardware.Camera.access$600(Camera.java:133)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at android.hardware.Camera$EventHandler.handleMessage(Camera.java:805)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at android.os.Handler.dispatchMessage(Handler.java:99)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at android.os.Looper.loop(Looper.java:137)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at android.app.ActivityThread.main(ActivityThread.java:4898)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at java.lang.reflect.Method.invokeNative(Native Method)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at java.lang.reflect.Method.invoke(Method.java:511)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
  06-20 12:13:25.725: E/AndroidRuntime(29033):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Does anybody came across this kind of situation. any help will be appreciated Thanks.</p>