I read the standard documentation related to Windows and checked its bunch of source code in an attempt to understand how and when Android Windows is created. I believe that I hugged him and would like to check it out or adjust it.
As far as I know, there are only two ways to get a handle to a Window object.
1. Activity getWindow. 2. Dialog getWindow method.
In both cases, you can get a window handle using getWindow and then manipulate the window using a handle.
Windows can also be created using the AddManView WindowManager method, but it is not possible to get a handle for such Windows. This is a very confusing area because the addView method itself does not involve creating a window and even a comment for it in the View Manager source code simply says the following.
Assign the passed LayoutParams to the passed View and add the view to the window.
Thus, it seems that the method involves adding a view to an existing Window. However, the second addView parameter is an instance of WindowManager.LayoutParams, which, among other things, determines the type of window (for example, TYPE_SYSTEM_ALERT), implying that the Window is actually a creation. This is essentially the case. Here's a very brief outline of what happens in the source code. (For beginners: you can view the source code on different sites; my favorite is http://grepcode.com .)
WindowManagerGlobal seems to be tracking multiple Windows through three arrays. As far as I can tell, ViewRootImpl is actually a new window and is controlled by WindowManagerGlobal.
Based on the foregoing, it seems that the addView call does create a new window (although it is called window and view in different ways), but it does not require the associated Window class to access it, so the developer cannot handle it.
My questions:
- Are there any ways to get a handle to a window instance other than the two getWindow methods mentioned above?
- Does addView really create a window, and if so, is there any way to get a handle to it?
- Is anything else wrong, and if so, in what respect (?)?
Thanks! Barry
source share