public final class WindowManagerImpl extends Object implements WindowManager
ViewManager
interface,
allowing you to add any View subclass as a top-level window on the screen.
Additional window manager specific layout parameters are defined for
control over how windows are displayed. It also implements the WindowManager
interface, allowing you to control the displays attached to the device.
Applications will not normally use WindowManager directly, instead relying
on the higher-level facilities in Activity
and
Dialog
.
Even for low-level window manager access, it is almost never correct to use
this class. For example, Activity.getWindowManager()
provides a window manager for adding windows that are associated with that
activity -- the window manager will not normally allow you to add arbitrary
windows that are not associated with an activity.
WindowManager
,
WindowManagerGlobal
WindowManager.BadTokenException, WindowManager.InvalidDisplayException, WindowManager.KeyboardShortcutsReceiver, WindowManager.LayoutParams
DOCKED_BOTTOM, DOCKED_INVALID, DOCKED_LEFT, DOCKED_RIGHT, DOCKED_TOP, PARCEL_KEY_SHORTCUTS_ARRAY, TAKE_SCREENSHOT_FULLSCREEN, TAKE_SCREENSHOT_SELECTED_REGION
Constructor and Description |
---|
WindowManagerImpl(Context context) |
Modifier and Type | Method and Description |
---|---|
void |
addView(View view,
ViewGroup.LayoutParams params)
Assign the passed LayoutParams to the passed View and add the view to the window.
|
WindowManagerImpl |
createLocalWindowManager(Window parentWindow) |
WindowManagerImpl |
createPresentationWindowManager(Context displayContext) |
Display |
getDefaultDisplay()
Returns the
Display upon which this WindowManager instance
will create new windows. |
void |
removeView(View view) |
void |
removeViewImmediate(View view)
Special variation of
ViewManager.removeView(android.view.View) that immediately invokes
the given view hierarchy's View.onDetachedFromWindow() methods before returning. |
void |
requestAppKeyboardShortcuts(WindowManager.KeyboardShortcutsReceiver receiver,
int deviceId)
Request for keyboard shortcuts to be retrieved asynchronously.
|
void |
setDefaultToken(IBinder token)
Sets the window token to assign when none is specified by the client or
available from the parent window.
|
void |
updateViewLayout(View view,
ViewGroup.LayoutParams params) |
public WindowManagerImpl(Context context)
public WindowManagerImpl createLocalWindowManager(Window parentWindow)
public WindowManagerImpl createPresentationWindowManager(Context displayContext)
public void setDefaultToken(IBinder token)
token
- The default token to assign.public void addView(View view, ViewGroup.LayoutParams params)
ViewManager
Throws WindowManager.BadTokenException
for certain programming
errors, such as adding a second view to a window without removing the first view.
Throws WindowManager.InvalidDisplayException
if the window is on a
secondary Display
and the specified display can't be found
(see Presentation
).
addView
in interface ViewManager
view
- The view to be added to this window.params
- The LayoutParams to assign to view.public void updateViewLayout(View view, ViewGroup.LayoutParams params)
updateViewLayout
in interface ViewManager
public void removeView(View view)
removeView
in interface ViewManager
public void removeViewImmediate(View view)
WindowManager
ViewManager.removeView(android.view.View)
that immediately invokes
the given view hierarchy's View.onDetachedFromWindow()
methods before returning. This is not
for normal applications; using it correctly requires great care.removeViewImmediate
in interface WindowManager
view
- The view to be removed.public void requestAppKeyboardShortcuts(WindowManager.KeyboardShortcutsReceiver receiver, int deviceId)
WindowManager
requestAppKeyboardShortcuts
in interface WindowManager
receiver
- The callback to be triggered when the result is ready.public Display getDefaultDisplay()
WindowManager
Display
upon which this WindowManager
instance
will create new windows.
Despite the name of this method, the display that is returned is not
necessarily the primary display of the system (see Display.DEFAULT_DISPLAY
).
The returned display could instead be a secondary display that this
window manager instance is managing. Think of it as the display that
this WindowManager
instance uses by default.
To create windows on a different display, you need to obtain a
WindowManager
for that Display
. (See the WindowManager
class documentation for more information.)
getDefaultDisplay
in interface WindowManager