Hi, Oops, sorry. I closed this bug by mistake, I reopened it, thanks for letting me know!
As for what you want to do, why exactly are you getting an exception in onCreateDialog()? All this method should be doing is instanciate a Dialog and its Views, nothing more. Populating the dialog should happen in onPrepareDialog(). On Sun, Jun 14, 2009 at 9:57 PM, Spencer Riddering<[email protected]> wrote: > > I've implemented the onCreateDialog(..) method in my Activity and I'm > working on the error handling. > > I wrap all my code in a try-catch so I can handle any errors. This > works great except that after handling an error I must still return a > value from onCreateDialog(..), either a Dialog instance or null. Since > an error has occurred I have no Dialog instance to return so I return > null. > > public Dialog onCreateDialog(int id){ > Dialog dialog = null; > try{ > // Exception thrown here. > dialog = .... > }catch(Exception e){ > // Error handled here. > dialog = null; // <----- What do I do here? ----- > } > } > > The problem is that returning null always results in Android popping > up a "Sorry" dialog error message. Like I said before, I already > handle my own errors so this additional Android "Sorry" dialog pops up > at the same time as my dialog. It's unnecessary and confusing to the > user. There appears to be no way to gracefully return from > onCreateDialog(..) after an error occurs. > > I submitted the issue here: > http://code.google.com/p/android/issues/detail?id=2985 > but Romainguy just declined it. He didn't leave a comment so I don't > know why. > > My question: > Why must returning an null result in an error? > Why can't nulls just be ignored? > > > > Here is my sample code demonstrating how returning null causes an > error both when the dialog is first created and immediately after a > configuration change. > http://android.googlecode.com/issues/attachment?aid=-2284006177336845437&name=CreateDialogHandleNull.java > > > > > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

