Have you tried restarting your phone and directly starting the stock / 
default camera app? Can you reproduce the problem then without starting 
your own app? If in that case the screen turns black again you probably 
have a faulty camera driver on your phone.

But in my own experience is probably related to a misuse or 
misconfiguration of the Camera object. On some devices the camera can be 
really fragile. Some drivers cannot cope with faulty settings or certain 
conditions. They crash and do not recover anymore unless you restart your 
phone.

First of all it is important to check the available features and 
resolutions returned by the Camera object. Do not set anything else than 
what is supported and provided by the camera.

Another important issue is the correct sequence of events according to your 
activity life cycle:


   - Activity.onResume
      - Camera.open
   - SurfaceHolder.Callback.surfaceCreated
      - camera.setPreviewDisplay
   - SurfaceHolder.Callback.surfaceChanged
      - camera.setParameters (only set a valid, available preview 
size<http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupportedPreviewSizes()>
      )
      - camera.startPreview
   - Activity.onPause
      - camera.stopPreview
      - camera.release
   
It is important to use onResume and onPause for opening and releasing the 
Camera object in order to avoid that these operations intersect with the 
life cycle of another Activity. If you release your camera in onStop or 
onDestroy for example a different Activity could already have executed 
onStart and do something with the camera at the same time.

On Tuesday, January 22, 2013 6:41:28 AM UTC-6, sameer khan wrote:
>
> I have developed the camera app to capture the image and it is working 
> fine.
> Someimes when we perform multiple clicks(4-5 times) on cam icon to capture 
> the image followed by home button, App unable to start the camera on 
> device. Same issue is reflected in default camera app as well.
>  
>  
>
>
> <https://lh6.googleusercontent.com/-9cR1VC3vkZI/UP6IpmQhdOI/AAAAAAAAABY/K5hQJOpTPxA/s1600/scanfront.png>
>  
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to