I'm creating a Modal Dialog that accepts touch events outside of the Dialog and can be positioned anywhere on the screen with any type of animation. Dialog does not allow this. It's basically a combination of a Toast and a Dialog with more options. It's quite useful and has a very specific use-case. This is all implemented at the platform level... this question just seemed more appropriate over here. I don't know why getWindow() is returning null. I could spend time debugging, but I've marked this as resolved. Thanks for taking the time to respond in detail. Your feedback led to the correct path. You are correct in that I am doing something 'unusual,' but that's because this functionality currently doesn't exist within the framework.
On Dec 4, 12:49 pm, Dianne Hackborn <[email protected]> wrote: > On Fri, Dec 4, 2009 at 12:31 PM, bizack <[email protected]> wrote: > > I would agree with you. I think the problem (or misunderstanding on > > my behalf) is that trying to call getWindowManager().addView outside > > of onCreate orphans the Window (getWindow() returns null). > > No it definitely doesn't. For example, dialogs and pop-up windows all use > this, and they work fine if called in onCreate or elsewhere. You must be > doing something else to cause getWindow() to return null... though I > honestly can't imagine what, since mWindow (which Activity.getWindow() > returns) is set in activity.attach() (which is called before onCreate()), > and never set to null after that. > > Also I would strongly strongly recommend using Dialog instead of directly > adding a view to the window manager, especially if this window is going to > receive key events, because Dialog implements a lot of the common > framework-side higher-level behavior for windows... such as, for example, > default key event handling. > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. 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

