Skip to content

Most visited

Recently visited

navigation

WindowManager

public interface WindowManager
implements ViewManager

android.view.WindowManager


The interface that apps use to talk to the window manager.

Each window manager instance is bound to a particular Display. To obtain a WindowManager for a different display, use createDisplayContext(Display) to obtain a Context for that display, then use Context.getSystemService(Context.WINDOW_SERVICE) to get the WindowManager.

The simplest way to show a window on another display is to create a Presentation. The presentation will automatically obtain a WindowManager and Context for that display.

Instances of this class must be obtained using Context.getSystemService(Class) with the argument WindowManager.class or Context.getSystemService(String) with the argument Context.WINDOW_SERVICE.

Summary

Nested classes

class WindowManager.BadTokenException

Exception that is thrown when trying to add view whose WindowManager.LayoutParams token is invalid. 

class WindowManager.InvalidDisplayException

Exception that is thrown when calling addView(View, ViewGroup.LayoutParams) to a secondary display that cannot be found. 

class WindowManager.LayoutParams

 

Public methods

abstract Display getDefaultDisplay()

Returns the Display upon which this WindowManager instance will create new windows.

abstract void removeViewImmediate(View view)

Special variation of removeView(View) that immediately invokes the given view hierarchy's View.onDetachedFromWindow() methods before returning.

Inherited methods

From interface android.view.ViewManager

Public methods

getDefaultDisplay

added in API level 1
Display getDefaultDisplay ()

Returns the 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 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.)

Returns
Display The display that this window manager is managing.

removeViewImmediate

added in API level 1
void removeViewImmediate (View view)

Special variation of removeView(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.

Parameters
view View: The view to be removed.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)