to top
Android APIs
public final class

DisplayManager

extends Object
java.lang.Object
   ↳ android.hardware.display.DisplayManager

Class Overview

Manages the properties of attached displays.

Get an instance of this class by calling Context.getSystemService() with the argument DISPLAY_SERVICE.

Summary

Nested Classes
interface DisplayManager.DisplayListener Listens for changes in available display devices. 
Constants
String DISPLAY_CATEGORY_PRESENTATION Display category: Presentation displays.
Public Methods
Display getDisplay(int displayId)
Gets information about a logical display.
Display[] getDisplays()
Gets all currently valid logical displays.
Display[] getDisplays(String category)
Gets all currently valid logical displays of the specified category.
void registerDisplayListener(DisplayManager.DisplayListener listener, Handler handler)
Registers an display listener to receive notifications about when displays are added, removed or changed.
void unregisterDisplayListener(DisplayManager.DisplayListener listener)
Unregisters an input device listener.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String DISPLAY_CATEGORY_PRESENTATION

Added in API level 17

Display category: Presentation displays.

This category can be used to identify secondary displays that are suitable for use as presentation displays.

Constant Value: "android.hardware.display.category.PRESENTATION"

Public Methods

public Display getDisplay (int displayId)

Added in API level 17

Gets information about a logical display. The display metrics may be adjusted to provide compatibility for legacy applications.

Parameters
displayId The logical display id.
Returns
  • The display object, or null if there is no valid display with the given id.

public Display[] getDisplays ()

Added in API level 17

Gets all currently valid logical displays.

Returns
  • An array containing all displays.

public Display[] getDisplays (String category)

Added in API level 17

Gets all currently valid logical displays of the specified category.

When there are multiple displays in a category the returned displays are sorted of preference. For example, if the requested category is DISPLAY_CATEGORY_PRESENTATION and there are multiple presentation displays then the displays are sorted so that the first display in the returned array is the most preferred presentation display. The application may simply use the first display or allow the user to choose.

Parameters
category The requested display category or null to return all displays.
Returns
  • An array containing all displays sorted by order of preference.

public void registerDisplayListener (DisplayManager.DisplayListener listener, Handler handler)

Added in API level 17

Registers an display listener to receive notifications about when displays are added, removed or changed.

Parameters
listener The listener to register.
handler The handler on which the listener should be invoked, or null if the listener should be invoked on the calling thread's looper.

public void unregisterDisplayListener (DisplayManager.DisplayListener listener)

Added in API level 17

Unregisters an input device listener.

Parameters
listener The listener to unregister.