java.lang.Object | |
↳ | android.hardware.display.DisplayManager |
Manages the properties of attached displays.
Get an instance of this class by calling
Context.getSystemService()
with the argument
DISPLAY_SERVICE
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DisplayManager.DisplayListener | Listens for changes in available display devices. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DISPLAY_CATEGORY_PRESENTATION | Display category: Presentation displays. | |||||||||
int | VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY | Virtual display flag: Only show this display's own content; do not mirror the content of another display. | |||||||||
int | VIRTUAL_DISPLAY_FLAG_PRESENTATION | Virtual display flag: Create a presentation display. | |||||||||
int | VIRTUAL_DISPLAY_FLAG_PUBLIC | Virtual display flag: Create a public display. | |||||||||
int | VIRTUAL_DISPLAY_FLAG_SECURE | Virtual display flag: Create a secure display. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a virtual display.
| |||||||||||
Gets information about a logical display.
| |||||||||||
Gets all currently valid logical displays.
| |||||||||||
Gets all currently valid logical displays of the specified category.
| |||||||||||
Registers an display listener to receive notifications about when
displays are added, removed or changed.
| |||||||||||
Unregisters an input device listener.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Display category: Presentation displays.
This category can be used to identify secondary displays that are suitable for use as presentation displays such as HDMI or Wireless displays. Applications may automatically project their content to presentation displays to provide richer second screen experiences.
Virtual display flag: Only show this display's own content; do not mirror the content of another display.
This flag is used in conjunction with VIRTUAL_DISPLAY_FLAG_PUBLIC
.
Ordinarily public virtual displays will automatically mirror the content of the
default display if they have no windows of their own. When this flag is
specified, the virtual display will only ever show its own content and
will be blanked instead if it has no windows.
Virtual display flag: Create a presentation display.
When this flag is set, the virtual display is registered as a presentation
display in the presentation display category
.
Applications may automatically project their content to presentation displays
to provide richer second screen experiences.
When this flag is not set, the virtual display is not registered as a presentation display. Applications can still project their content on the display but they will typically not do so automatically. This option is appropriate for more special-purpose displays.
Virtual display flag: Create a public display.
When this flag is set, the virtual display is public.
A public virtual display behaves just like most any other display that is connected to the system such as an HDMI or Wireless display. Applications can open windows on the display and the system may mirror the contents of other displays onto it.
Creating a public virtual display requires the
CAPTURE_VIDEO_OUTPUT
or CAPTURE_SECURE_VIDEO_OUTPUT
permission.
These permissions are reserved for use by system components and are not available to
third-party applications.
When this flag is not set, the virtual display is private as defined by the
FLAG_PRIVATE
display flag.
Virtual display flag: Create a secure display.
When this flag is set, the virtual display is considered secure as defined
by the FLAG_SECURE
display flag. The caller promises to take
reasonable measures, such as over-the-air encryption, to prevent the contents
of the display from being intercepted or recorded on a persistent medium.
Creating a secure virtual display requires the
CAPTURE_SECURE_VIDEO_OUTPUT
permission.
This permission is reserved for use by system components and is not available to
third-party applications.
When this flag is not set, the virtual display is considered unsecure. The content of secure windows will be blanked if shown on this display.
Creates a virtual display.
The content of a virtual display is rendered to a Surface
provided
by the application.
The virtual display should be released
when no longer needed. Because a virtual display renders to a surface
provided by the application, it will be released automatically when the
process terminates and all remaining windows on it will be forcibly removed.
The behavior of the virtual display depends on the flags that are provided to this method. By default, virtual displays are created to be private, non-presentation and unsecure. Permissions may be required to use certain flags.
As of KITKAT_WATCH
, the surface may
be attached or detached dynamically using setSurface(Surface)
.
Previously, the surface had to be non-null when createVirtualDisplay(String, int, int, int, Surface, int)
was called and could not be changed for the lifetime of the display.
Detaching the surface that backs a virtual display has a similar effect to turning off the screen.
name | The name of the virtual display, must be non-empty. |
---|---|
width | The width of the virtual display in pixels, must be greater than 0. |
height | The height of the virtual display in pixels, must be greater than 0. |
densityDpi | The density of the virtual display in dpi, must be greater than 0. |
surface | The surface to which the content of the virtual display should be rendered, or null if there is none initially. |
flags | A combination of virtual display flags:
VIRTUAL_DISPLAY_FLAG_PUBLIC , VIRTUAL_DISPLAY_FLAG_PRESENTATION ,
VIRTUAL_DISPLAY_FLAG_SECURE , or VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY . |
SecurityException | if the caller does not have permission to create a virtual display with the specified flags. |
---|
Gets information about a logical display. The display metrics may be adjusted to provide compatibility for legacy applications.
displayId | The logical display id. |
---|
Gets all currently valid logical displays.
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.
category | The requested display category or null to return all displays. |
---|
Registers an display listener to receive notifications about when displays are added, removed or changed.
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. |
Unregisters an input device listener.
listener | The listener to unregister. |
---|