It's a dirty work-around, but call the onPrepareDialog yourself if it has not been called after a config-change.
On Jun 15, 10:52 am, Spencer Riddering <[email protected]> wrote: > Hi Romain Guy, > > So, I updated the original issue. > > I don't see a problem with leaving the code as it is as long as I can > prevent the "Sorry" dialog of death (SDOD). As I mentioned in the > issue tracker, wrapping the showDialog(..) call in a try-catch > prevents the SDOD. The problem is that during a configuration change I > have no way to contain the error and I can't do my dialog > initialization in onPrepareDialog(..) because onPrepareDialog(..) is > not called (see issue #1639 ). So, currently no way to contain dialog > creation errors during configuration changes. > > On Jun 15, 1:23 pm, Romain Guy <[email protected]> wrote: > > > > > 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=-2284006177336845... > > > -- > > 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- Hide quoted text > > - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

