# DisplayManagerCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/hardware/display/DisplayManagerCompat.java+class:androidx.core.hardware.display.DisplayManagerCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public final class DisplayManagerCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/hardware/display/DisplayManager.html`.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/core/hardware/display/ExperimentalDisplayApi https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#DISPLAY_CATEGORY_BUILT_IN_DISPLAYS() = "android.hardware.display.category.BUILT_IN_DISPLAYS"` Display category: Built in displays. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#DISPLAY_CATEGORY_PRESENTATION() = "android.hardware.display.category.PRESENTATION"` Display category: Presentation displays. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/Display.html` | `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#getDisplay(int)(int displayId)` Gets information about a logical display. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Display[]` | `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#getDisplays()()` Gets all currently valid logical displays. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Display[]` | `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#getDisplays(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html category)` Gets all currently valid logical displays of the specified category. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat` | `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#getInstance(android.content.Context)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context)` Gets an instance of the display manager given the context. |

## Constants

### DISPLAY_CATEGORY_BUILT_IN_DISPLAYS

Added in [1.16.0](https://developer.android.com/jetpack/androidx/releases/core#1.16.0)

```
@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 |
|---|---|
| `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#getDisplays(java.lang.String)` |   |

### DISPLAY_CATEGORY_PRESENTATION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
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 |
|---|---|
| `https://developer.android.com/reference/android/app/Presentation.html` | for information about presenting content on secondary displays. |
| `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#getDisplays(java.lang.String)` |   |

## Public methods

### getDisplay

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
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. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/Display.html` | The display object, or null if there is no valid display with the given id. |

### getDisplays

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @NonNull Display[] getDisplays()
```

Gets all currently valid logical displays.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Display[]` | An array containing all displays. |

### getDisplays

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
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 `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html category` | The requested display category or null to return all displays. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Display[]` | An array containing all displays sorted by order of preference. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat#DISPLAY_CATEGORY_PRESENTATION()` |   |

### getInstance

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static @NonNull DisplayManagerCompat getInstance(@NonNull Context context)
```

Gets an instance of the display manager given the context.