# MediaDrm.KeyStatus

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# KeyStatus

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/MediaDrm.KeyStatus "View this page in Java")  

```
class KeyStatus
```

|---|----------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                       ||
| ↳ | [android.media.MediaDrm.KeyStatus](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#) |

Defines the status of a key. A KeyStatus for each key in a session is provided to the[OnKeyStatusChangeListener.onKeyStatusChange](https://developer.android.com/reference/kotlin/android/media/MediaDrm.OnKeyStatusChangeListener#onKeyStatusChange(android.media.MediaDrm,%20kotlin.ByteArray,%20kotlin.collections.MutableList,%20kotlin.Boolean))listener.

## Summary

|                                                                                                                                                                          Constants                                                                                                                                                                          ||
|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATUS_EXPIRED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_EXPIRED:kotlin.Int) The key is no longer usable to decrypt media data because its expiration time has passed.                                                     |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATUS_INTERNAL_ERROR](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_INTERNAL_ERROR:kotlin.Int) The key is not currently usable to decrypt media data because of an internal error in processing unrelated to input parameters. |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATUS_OUTPUT_NOT_ALLOWED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_OUTPUT_NOT_ALLOWED:kotlin.Int) The key is not currently usable to decrypt media data because its output requirements cannot currently be met.          |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATUS_PENDING](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_PENDING:kotlin.Int) The status of the key is not yet known and is being determined.                                                                               |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATUS_USABLE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_USABLE:kotlin.Int) The key is currently usable to decrypt media data                                                                                               |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATUS_USABLE_IN_FUTURE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_USABLE_IN_FUTURE:kotlin.Int) The key is not yet usable to decrypt media because the start time is in the future.                                         |

|                                                                                                                  Public methods                                                                                                                   ||
|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html) | [getKeyId](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#getKeyId())`()` Returns the id for the key                    |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)              | [getStatusCode](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#getStatusCode())`()` Returns the status code for the key |

## Constants

### STATUS_EXPIRED

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATUS_EXPIRED: Int
```

The key is no longer usable to decrypt media data because its expiration time has passed.  

    Value: 1

### STATUS_INTERNAL_ERROR

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATUS_INTERNAL_ERROR: Int
```

The key is not currently usable to decrypt media data because of an internal error in processing unrelated to input parameters. This error is not actionable by an app.  

    Value: 4

### STATUS_OUTPUT_NOT_ALLOWED

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATUS_OUTPUT_NOT_ALLOWED: Int
```

The key is not currently usable to decrypt media data because its output requirements cannot currently be met.  

    Value: 2

### STATUS_PENDING

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATUS_PENDING: Int
```

The status of the key is not yet known and is being determined. The status will be updated with the actual status when it has been determined.  

    Value: 3

### STATUS_USABLE

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATUS_USABLE: Int
```

The key is currently usable to decrypt media data  

    Value: 0

### STATUS_USABLE_IN_FUTURE

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATUS_USABLE_IN_FUTURE: Int
```

The key is not yet usable to decrypt media because the start time is in the future. The key will become usable when its start time is reached.  

    Value: 5

## Public methods

### getKeyId

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getKeyId(): ByteArray
```

Returns the id for the key

|                                                        Return                                                        ||
|-----------------------------------------------------------------------------------------|-----------------------------|
| [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html) | This value cannot be`null`. |

### getStatusCode

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getStatusCode(): Int
```

Returns the status code for the key

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Return                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is[android.media.MediaDrm.KeyStatus#STATUS_USABLE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_USABLE:kotlin.Int),[android.media.MediaDrm.KeyStatus#STATUS_EXPIRED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_EXPIRED:kotlin.Int),[android.media.MediaDrm.KeyStatus#STATUS_OUTPUT_NOT_ALLOWED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_OUTPUT_NOT_ALLOWED:kotlin.Int),[android.media.MediaDrm.KeyStatus#STATUS_PENDING](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_PENDING:kotlin.Int),[android.media.MediaDrm.KeyStatus#STATUS_INTERNAL_ERROR](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_INTERNAL_ERROR:kotlin.Int), or[android.media.MediaDrm.KeyStatus#STATUS_USABLE_IN_FUTURE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.KeyStatus#STATUS_USABLE_IN_FUTURE:kotlin.Int) |