I am migrating some of my activities to FragmentActivity using the 
compatibility library. 
I was using onRetainNonConfigurationInstance() to save an AsyncTask between 
re-creations, but since this is now final, the recommended approach seems to 
be 
to replace my AsyncTask with a loader. I now have a class derived from 
AsyncTaskLoader that does basically the same thing as the old AsyncTask, and 
I am 
trying to figure out what the best approach to handle load errors is. 

LoaderManger/Loader don't have any support for error handling (no 
onLoadError(), 
etc. Why?), and any unhandled exceptions just bubble up. Which means one 
needs 
to make sure loadInBackground() doesn't throw and get your process killed 
(at least 
that's what happens when using the compatibility library). To pass error 
info to the 
callback you need to either:

 1.  use the return value: wrap any results in a class that has an 
Exception 
  member in addition to the actual result, and check if is null or not in 
  onLoaderFinished(); or
 2. save the error state in the Loader, cast it in onLoaderFinished() and 
check 
 for errors

1. seems rather awkward if type safe, 2. is not too pretty either. Any other 
ideas?



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