# DisplayManagerCompat

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/hardware/display/DisplayManagerCompat "View this page in Java")

<br />

```
class DisplayManagerCompat
```

<br />

*** ** * ** ***

Helper for accessing features in[android.hardware.display.DisplayManager](https://developer.android.com/reference/android/hardware/display/DisplayManager.html).

## Summary

|                                        ### Constants                                         |
|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | `@`[ExperimentalDisplayApi](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/ExperimentalDisplayApi) [DISPLAY_CATEGORY_BUILT_IN_DISPLAYS](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat#DISPLAY_CATEGORY_BUILT_IN_DISPLAYS())` = "android.hardware.display.category.BUILT_IN_DISPLAYS"` Display category: Built in displays. |
| `const `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | [DISPLAY_CATEGORY_PRESENTATION](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat#DISPLAY_CATEGORY_PRESENTATION())` = "android.hardware.display.category.PRESENTATION"` Display category: Presentation displays.                                                                                                                                              |

|                                                                        ### Public functions                                                                        |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Display](https://developer.android.com/reference/android/view/Display.html)`?`                                                                                    | [getDisplay](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat#getDisplay(int))`(displayId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Gets information about a logical display.                                                 |
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Display](https://developer.android.com/reference/android/view/Display.html)`!>` | [getDisplays](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat#getDisplays())`()` Gets all currently valid logical displays.                                                                                                                                         |
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Display](https://developer.android.com/reference/android/view/Display.html)`!>` | [getDisplays](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat#getDisplays(java.lang.String))`(category: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?)` Gets all currently valid logical displays of the specified category. |
| `java-static `[DisplayManagerCompat](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat)                           | [getInstance](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat#getInstance(android.content.Context))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`)` 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
const val DISPLAY_CATEGORY_BUILT_IN_DISPLAYS = "android.hardware.display.category.BUILT_IN_DISPLAYS": String!
```

Display category: Built in displays.

This category can be used to identify displays that are built in to the device.  

|                                                                    See also                                                                     |
|-------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getDisplays](https://developer.android.com/reference/kotlin/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)  

```
const val DISPLAY_CATEGORY_PRESENTATION = "android.hardware.display.category.PRESENTATION": String!
```

Display category: Presentation displays.

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

|                                                                    See also                                                                     |
|-------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [Presentation](https://developer.android.com/reference/android/app/Presentation.html)                                                           | for information about presenting content on secondary displays. |
| [getDisplays](https://developer.android.com/reference/kotlin/androidx/core/hardware/display/DisplayManagerCompat#getDisplays(java.lang.String)) |                                                                 |

## Public functions

### getDisplay

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

```
fun getDisplay(displayId: Int): Display?
```

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

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|-------------------------|
| `displayId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The logical display id. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| [Display](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)  

```
fun getDisplays(): Array<Display!>
```

Gets all currently valid logical displays.  

|                                                                              Returns                                                                               |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Display](https://developer.android.com/reference/android/view/Display.html)`!>` | An array containing all displays. |

### getDisplays

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

```
fun getDisplays(category: String?): Array<Display!>
```

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](https://developer.android.com/reference/kotlin/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                                            |
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| `category: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | The requested display category or null to return all displays. |

|                                                                              Returns                                                                               |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Display](https://developer.android.com/reference/android/view/Display.html)`!>` | An array containing all displays sorted by order of preference. |

|                                                                              See also                                                                               |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [DISPLAY_CATEGORY_PRESENTATION](https://developer.android.com/reference/kotlin/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)  

```
java-static fun getInstance(context: Context): DisplayManagerCompat
```

Gets an instance of the display manager given the context.