DisplayManagerCompat
public final class DisplayManagerCompat
Helper for accessing features in android.hardware.display.DisplayManager.
Summary
Constants |
|
|---|---|
static final String |
@ExperimentalDisplayApiDisplay category: Built in displays. |
static final String |
DISPLAY_CATEGORY_PRESENTATION = "android.hardware.display.category.PRESENTATION"Display category: Presentation displays. |
Public methods |
|
|---|---|
@Nullable Display |
getDisplay(int displayId)Gets information about a logical display. |
@NonNull Display[] |
Gets all currently valid logical displays. |
@NonNull Display[] |
getDisplays(@Nullable String category)Gets all currently valid logical displays of the specified category. |
static @NonNull DisplayManagerCompat |
getInstance(@NonNull Context context)Gets an instance of the display manager given the context. |
Constants
DISPLAY_CATEGORY_BUILT_IN_DISPLAYS
@ExperimentalDisplayApi
public static final String DISPLAY_CATEGORY_BUILT_IN_DISPLAYS = "android.hardware.display.category.BUILT_IN_DISPLAYS"
Display category: Built in displays.
This category can be used to identify displays that are built in to the device.
| See also | |
|---|---|
getDisplays |
DISPLAY_CATEGORY_PRESENTATION
public static final String DISPLAY_CATEGORY_PRESENTATION = "android.hardware.display.category.PRESENTATION"
Display category: Presentation displays.
This category can be used to identify secondary displays that are suitable for use as presentation displays.
| See also | |
|---|---|
Presentation |
for information about presenting content on secondary displays. |
getDisplays |
Public methods
getDisplay
public @Nullable Display getDisplay(int displayId)
Gets information about a logical display. The display metrics may be adjusted to provide compatibility for legacy applications.
| Parameters | |
|---|---|
int displayId |
The logical display id. |
getDisplays
public @NonNull Display[] getDisplays()
Gets all currently valid logical displays.
| Returns | |
|---|---|
@NonNull Display[] |
An array containing all displays. |
getDisplays
public @NonNull Display[] getDisplays(@Nullable String category)
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.
| Returns | |
|---|---|
@NonNull Display[] |
An array containing all displays sorted by order of preference. |
| See also | |
|---|---|
DISPLAY_CATEGORY_PRESENTATION |
getInstance
public static @NonNull DisplayManagerCompat getInstance(@NonNull Context context)
Gets an instance of the display manager given the context.