in my camera app, the media recorder stop is called on the main UI thread. 
Both the developer reference at the android site, as well as android camera 
reference code seem to do the same thing (call stop on the main UI thread).

However under certain scenarios, (SD card is slow, parallel IO is going on, 
SD card is highly fragmented and near full), it seems that stop takes a 
long time to return (30-200 seconds). I imagine this happens because the 
I/O operations that occur as part of media recorder stop (to save the 
recorded video file) take time to finish.

This can result in ANR as the main UI thread seems to be occupied for a 
duration greater than 5 seconds.

My first instinct was to move the media recorder stop in a separate thread, 
so that UI thread is free. However, doing that can lead to a few risky 
scenarios. If the user exits the app, while saving is going, there is no 
sure way to kill this thread (which is stuck on stop()). And if the media 
recorder is not stopped (and released), the user cannot use any other app 
(gtalk for example) which might need a media recorder instance. Further 
android recommends releasing media recorder in onPause, which would mean I 
should join this thread in onPause. This would result in an ANR if the user 
pressed back.

Are there any suggestions as to how best to handle this situation? I 
imagine, there must be other people who have encountered a similar scenario.

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

Reply via email to