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