Hi,

I tried to search for a solution to a general problem I am having and
came up empty.  I'm posting the following question in hopes someone
else has come across this and might know the answer and can share it.

I have an application that contains an activity and a service.  The
activity through the GUI connects to the the service and starts a
background process to write data out to the SD card.  The scenario I'm
trying to handle is if the end-user pulls the SD card out during the
background process writes being performed.  I have a broadcast
receiver in my service which is registered and does receive the event
indicating the media has been unmounted.  When my receiver receives
this event, it attempts to interrupt the background writing in order
to stop and clean up.  I'm currently using buffered I/O (not sure if
this is the reason for my problem) and so when the service detects it
needs to stop writing and clean up, it attempts to do so after closing
the open file streams.  The calls to 'close' on my buffered output
streams are failing due to the SD card being removed.  After all the
attempts have failed, the Android runtime is killing any processes
that have open file streams to the SD card and so my process (Activity
+ Service) is going away.  I could place the Activity and Service in
to separate processes such that my activity should survive but service
still punted (restarted on an as-needed basis), but I would rather see
if there's a more graceful way to handle unflushed I/O such that the
process containing my activity and service does not get reaped.

Any thoughts, ideas would be greatly appreciated.

Andy
--~--~---------~--~----~------------~-------~--~----~
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