# MediaDrm.MediaDrmStateException

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

# MediaDrmStateException

*** ** * ** ***

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

```
class MediaDrmStateException : IllegalStateException, MediaDrmThrowable
```

|---|---|---|---|---|------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                             ||||||
| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)                                                              |||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)                                                         ||||
|   |   | ↳ | [java.lang.RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException.html#)                                        |||
|   |   |   | ↳ | [java.lang.IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException.html#)                           ||
|   |   |   |   | ↳ | [android.media.MediaDrm.MediaDrmStateException](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#) |

Thrown when a general failure occurs during a MediaDrm operation. Extends[IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException.html#)with the addition of an error code that may be useful in diagnosing the failure.

Please refer to[ErrorCodes](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes)for the general error handling strategy and details about each possible return value from[android.media.MediaDrm.MediaDrmStateException#getErrorCode()](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#getErrorCode()).

## Summary

|                                                                                                                                                                                                                                             Public methods                                                                                                                                                                                                                                             ||
|------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)   | [getDiagnosticInfo](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#getDiagnosticInfo())`()` Retrieve a developer-readable diagnostic information string associated with the exception.                                                                                                                                                                               |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getErrorCode](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#getErrorCode())`()` Returns error code associated with this[MediaDrmStateException](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#).                                                                                                                    |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getErrorContext](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#getErrorContext())`()` <br />                                                                                                                                                                                                                                                                       |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getOemError](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#getOemError())`()` <br />                                                                                                                                                                                                                                                                               |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getVendorError](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#getVendorError())`()` <br />                                                                                                                                                                                                                                                                         |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isTransient](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#isTransient())`()` Returns true if the[MediaDrmStateException](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#)is a transient issue, perhaps due to resource constraints, and that the operation (e.g. provisioning) may succeed on a subsequent attempt. |

## Public methods

### getDiagnosticInfo

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

```
fun getDiagnosticInfo(): String
```

Retrieve a developer-readable diagnostic information string associated with the exception. Do not show this to end-users, since this string will not be localized or generally comprehensible to end-users.

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

### getErrorCode

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

```
fun getErrorCode(): Int
```

Returns error code associated with this[MediaDrmStateException](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#).

Please refer to[ErrorCodes](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes)for the general error handling strategy and details about each possible return value.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Return                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | an error code defined in[MediaDrm.ErrorCodes](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes). Value is[android.media.MediaDrm.ErrorCodes#ERROR_NO_KEY](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_NO_KEY:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_KEY_EXPIRED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_KEY_EXPIRED:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_RESOURCE_BUSY](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_RESOURCE_BUSY:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_INSUFFICIENT_OUTPUT_PROTECTION](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_INSUFFICIENT_OUTPUT_PROTECTION:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_SESSION_NOT_OPENED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_SESSION_NOT_OPENED:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_UNSUPPORTED_OPERATION](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_UNSUPPORTED_OPERATION:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_INSUFFICIENT_SECURITY](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_INSUFFICIENT_SECURITY:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_FRAME_TOO_LARGE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_FRAME_TOO_LARGE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_LOST_STATE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_LOST_STATE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_CERTIFICATE_MALFORMED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_CERTIFICATE_MALFORMED:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_CERTIFICATE_MISSING](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_CERTIFICATE_MISSING:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_CRYPTO_LIBRARY](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_CRYPTO_LIBRARY:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_GENERIC_OEM](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_GENERIC_OEM:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_GENERIC_PLUGIN](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_GENERIC_PLUGIN:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_INIT_DATA](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_INIT_DATA:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_KEY_NOT_LOADED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_KEY_NOT_LOADED:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_LICENSE_PARSE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_LICENSE_PARSE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_LICENSE_POLICY](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_LICENSE_POLICY:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_LICENSE_RELEASE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_LICENSE_RELEASE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_LICENSE_REQUEST_REJECTED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_LICENSE_REQUEST_REJECTED:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_LICENSE_RESTORE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_LICENSE_RESTORE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_LICENSE_STATE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_LICENSE_STATE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_MEDIA_FRAMEWORK](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_MEDIA_FRAMEWORK:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_PROVISIONING_CERTIFICATE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_PROVISIONING_CERTIFICATE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_PROVISIONING_CONFIG](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_PROVISIONING_CONFIG:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_PROVISIONING_PARSE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_PROVISIONING_PARSE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_PROVISIONING_REQUEST_REJECTED](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_PROVISIONING_REQUEST_REJECTED:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_PROVISIONING_RETRY](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_PROVISIONING_RETRY:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_SECURE_STOP_RELEASE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_SECURE_STOP_RELEASE:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_STORAGE_READ](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_STORAGE_READ:kotlin.Int),[android.media.MediaDrm.ErrorCodes#ERROR_STORAGE_WRITE](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_STORAGE_WRITE:kotlin.Int), or[android.media.MediaDrm.ErrorCodes#ERROR_ZERO_SUBSAMPLES](https://developer.android.com/reference/kotlin/android/media/MediaDrm.ErrorCodes#ERROR_ZERO_SUBSAMPLES:kotlin.Int) |

### getErrorContext

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

```
fun getErrorContext(): Int
```

|                                                                                                                                Return                                                                                                                                ||
|----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | an opaque integer that would help the @[MediaDrm](https://developer.android.com/reference/kotlin/android/media/MediaDrm)vendor locate the source of the error if available, otherwise 0. |

### getOemError

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

```
fun getOemError(): Int
```

|                                                                  Return                                                                  ||
|----------------------------------------------------------------------------|--------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | an OEM or SOC specific error code if available, otherwise 0. |

### getVendorError

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

```
fun getVendorError(): Int
```

|                                                                                                              Return                                                                                                               ||
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | an error code defined by the[MediaDrm](https://developer.android.com/reference/kotlin/android/media/MediaDrm)plugin vendor if available, otherwise 0. |

### isTransient

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

```
fun isTransient(): Boolean
```

Returns true if the[MediaDrmStateException](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException#)is a transient issue, perhaps due to resource constraints, and that the operation (e.g. provisioning) may succeed on a subsequent attempt.