# IllegalStateException

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

# IllegalStateException

```
open class IllegalStateException : RuntimeException
```

|---|---|---|---|--------------------------------------------------------------------------------------------------------------------|
| [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)                                |||
|   |   | ↳ | [java.lang.RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException)               ||
|   |   |   | ↳ | [java.lang.IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException#) |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [AcceptPendingException](https://developer.android.com/reference/kotlin/java/nio/channels/AcceptPendingException.html#),[AlreadyBoundException](https://developer.android.com/reference/kotlin/java/nio/channels/AlreadyBoundException.html#),[AlreadyConnectedException](https://developer.android.com/reference/kotlin/java/nio/channels/AlreadyConnectedException.html#),[CancellationException](https://developer.android.com/reference/kotlin/java/util/concurrent/CancellationException.html#),[CancelledKeyException](https://developer.android.com/reference/kotlin/java/nio/channels/CancelledKeyException.html#),[ClosedDirectoryStreamException](https://developer.android.com/reference/kotlin/java/nio/file/ClosedDirectoryStreamException.html#),[ClosedFileSystemException](https://developer.android.com/reference/kotlin/java/nio/file/ClosedFileSystemException.html#),[ClosedSelectorException](https://developer.android.com/reference/kotlin/java/nio/channels/ClosedSelectorException.html#),[ClosedWatchServiceException](https://developer.android.com/reference/kotlin/java/nio/file/ClosedWatchServiceException.html#),[ConnectionPendingException](https://developer.android.com/reference/kotlin/java/nio/channels/ConnectionPendingException.html#),[FormatterClosedException](https://developer.android.com/reference/kotlin/java/util/FormatterClosedException.html#),[IllegalBlockingModeException](https://developer.android.com/reference/kotlin/java/nio/channels/IllegalBlockingModeException.html#), and 18 others. |-------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AcceptPendingException](https://developer.android.com/reference/kotlin/java/nio/channels/AcceptPendingException.html#)                                           | Unchecked exception thrown when an attempt is made to initiate an accept operation on a channel and a previous accept operation has not completed.                                                                                                                                                                                                                                                                                                             | | [AlreadyBoundException](https://developer.android.com/reference/kotlin/java/nio/channels/AlreadyBoundException.html#)                                             | Unchecked exception thrown when an attempt is made to bind the socket a network oriented channel that is already bound.                                                                                                                                                                                                                                                                                                                                        | | [AlreadyConnectedException](https://developer.android.com/reference/kotlin/java/nio/channels/AlreadyConnectedException.html#)                                     | Unchecked exception thrown when an attempt is made to connect a[SocketChannel](https://developer.android.com/reference/kotlin/java/nio/channels/SocketChannel.html#)that is already connected.                                                                                                                                                                                                                                                                 | | [CancellationException](https://developer.android.com/reference/kotlin/java/util/concurrent/CancellationException.html#)                                          | Exception indicating that the result of a value-producing task, such as a[FutureTask](https://developer.android.com/reference/kotlin/java/util/concurrent/FutureTask.html#), cannot be retrieved because the task was cancelled.                                                                                                                                                                                                                               | | [CancelledKeyException](https://developer.android.com/reference/kotlin/java/nio/channels/CancelledKeyException.html#)                                             | Unchecked exception thrown when an attempt is made to use a selection key that is no longer valid.                                                                                                                                                                                                                                                                                                                                                             | | [ClosedDirectoryStreamException](https://developer.android.com/reference/kotlin/java/nio/file/ClosedDirectoryStreamException.html#)                               | Unchecked exception thrown when an attempt is made to invoke an operation on a directory stream that is closed.                                                                                                                                                                                                                                                                                                                                                | | [ClosedFileSystemException](https://developer.android.com/reference/kotlin/java/nio/file/ClosedFileSystemException.html#)                                         | Unchecked exception thrown when an attempt is made to invoke an operation on a file and the file system is closed.                                                                                                                                                                                                                                                                                                                                             | | [ClosedSelectorException](https://developer.android.com/reference/kotlin/java/nio/channels/ClosedSelectorException.html#)                                         | Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a closed selector.                                                                                                                                                                                                                                                                                                                                                          | | [ClosedWatchServiceException](https://developer.android.com/reference/kotlin/java/nio/file/ClosedWatchServiceException.html#)                                     | Unchecked exception thrown when an attempt is made to invoke an operation on a watch service that is closed.                                                                                                                                                                                                                                                                                                                                                   | | [ConnectionPendingException](https://developer.android.com/reference/kotlin/java/nio/channels/ConnectionPendingException.html#)                                   | Unchecked exception thrown when an attempt is made to connect a[SocketChannel](https://developer.android.com/reference/kotlin/java/nio/channels/SocketChannel.html#)for which a non-blocking connection operation is already in progress.                                                                                                                                                                                                                      | | [FormatterClosedException](https://developer.android.com/reference/kotlin/java/util/FormatterClosedException.html#)                                               | Unchecked exception thrown when the formatter has been closed.                                                                                                                                                                                                                                                                                                                                                                                                 | | [IllegalBlockingModeException](https://developer.android.com/reference/kotlin/java/nio/channels/IllegalBlockingModeException.html#)                               | Unchecked exception thrown when a blocking-mode-specific operation is invoked upon a channel in the incorrect blocking mode.                                                                                                                                                                                                                                                                                                                                   | | [InvalidMarkException](https://developer.android.com/reference/kotlin/java/nio/InvalidMarkException.html#)                                                        | Unchecked exception thrown when an attempt is made to reset a buffer when its mark is not defined.                                                                                                                                                                                                                                                                                                                                                             | | [LimitExceededException](https://developer.android.com/reference/kotlin/android/os/LimitExceededException.html#)                                                  | Indicates that the app has exceeded a limit set by the System.                                                                                                                                                                                                                                                                                                                                                                                                 | | [MediaCasStateException](https://developer.android.com/reference/kotlin/android/media/MediaCasStateException.html#)                                               | Base class for MediaCas runtime exceptions                                                                                                                                                                                                                                                                                                                                                                                                                     | | [MediaCodec.CodecException](https://developer.android.com/reference/kotlin/android/media/MediaCodec.CodecException.html#)                                         | Thrown when an internal codec error occurs.                                                                                                                                                                                                                                                                                                                                                                                                                    | | [MediaDrm.MediaDrmStateException](https://developer.android.com/reference/kotlin/android/media/MediaDrm.MediaDrmStateException.html#)                             | Thrown when a general failure occurs during a MediaDrm operation.                                                                                                                                                                                                                                                                                                                                                                                              | | [MediaDrmResetException](https://developer.android.com/reference/kotlin/android/media/MediaDrmResetException.html#)                                               | This exception is thrown when the MediaDrm instance has become unusable due to a restart of the mediaserver process.                                                                                                                                                                                                                                                                                                                                           | | [NoConnectionPendingException](https://developer.android.com/reference/kotlin/java/nio/channels/NoConnectionPendingException.html#)                               | Unchecked exception thrown when the[finishConnect](https://developer.android.com/reference/kotlin/java/nio/channels/SocketChannel.html#finishConnect())method of a[SocketChannel](https://developer.android.com/reference/kotlin/java/nio/channels/SocketChannel.html#)is invoked without first successfully invoking its[connect](https://developer.android.com/reference/kotlin/java/nio/channels/SocketChannel.html#connect(java.net.SocketAddress))method. | | [NonReadableChannelException](https://developer.android.com/reference/kotlin/java/nio/channels/NonReadableChannelException.html#)                                 | Unchecked exception thrown when an attempt is made to read from a channel that was not originally opened for reading.                                                                                                                                                                                                                                                                                                                                          | | [NonWritableChannelException](https://developer.android.com/reference/kotlin/java/nio/channels/NonWritableChannelException.html#)                                 | Unchecked exception thrown when an attempt is made to write to a channel that was not originally opened for writing.                                                                                                                                                                                                                                                                                                                                           | | [NotYetBoundException](https://developer.android.com/reference/kotlin/java/nio/channels/NotYetBoundException.html#)                                               | Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a server socket channel that is not yet bound.                                                                                                                                                                                                                                                                                                                              | | [NotYetConnectedException](https://developer.android.com/reference/kotlin/java/nio/channels/NotYetConnectedException.html#)                                       | Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a socket channel that is not yet connected.                                                                                                                                                                                                                                                                                                                                 | | [OverlappingFileLockException](https://developer.android.com/reference/kotlin/java/nio/channels/OverlappingFileLockException.html#)                               | Unchecked exception thrown when an attempt is made to acquire a lock on a region of a file that overlaps a region already locked by the same Java virtual machine, or when another thread is already waiting to lock an overlapping region of the same file.                                                                                                                                                                                                   | | [ReadPendingException](https://developer.android.com/reference/kotlin/java/nio/channels/ReadPendingException.html#)                                               | Unchecked exception thrown when an attempt is made to read from an asynchronous socket channel and a previous read has not completed.                                                                                                                                                                                                                                                                                                                          | | [ServiceStartNotAllowedException](https://developer.android.com/reference/kotlin/android/app/ServiceStartNotAllowedException.html#)                               | Exception thrown when an app tries to start a[Service](https://developer.android.com/reference/kotlin/android/app/Service.html#)when it's not allowed to do so.                                                                                                                                                                                                                                                                                                | | [ShutdownChannelGroupException](https://developer.android.com/reference/kotlin/java/nio/channels/ShutdownChannelGroupException.html#)                             | Unchecked exception thrown when an attempt is made to construct a channel in a group that is shutdown or the completion handler for an I/O operation cannot be invoked because the channel group has terminated.                                                                                                                                                                                                                                               | | [StartForegroundCalledOnStoppedServiceException](https://developer.android.com/reference/kotlin/android/app/StartForegroundCalledOnStoppedServiceException.html#) | Exception thrown when android.                                                                                                                                                                                                                                                                                                                                                                                                                                 | | [UnsafeStateException](https://developer.android.com/reference/kotlin/android/app/admin/UnsafeStateException.html#)                                               | Exception thrown when a[android.app.admin.DevicePolicyManager](https://developer.android.com/reference/kotlin/android/app/admin/DevicePolicyManager.html#)operation failed because it was not safe to be executed at that moment.                                                                                                                                                                                                                              | | [WritePendingException](https://developer.android.com/reference/kotlin/java/nio/channels/WritePendingException.html#)                                             | Unchecked exception thrown when an attempt is made to write to an asynchronous socket channel and a previous write has not completed.                                                                                                                                                                                                                                                                                                                          | |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Indirect Subclasses [BackgroundServiceStartNotAllowedException](https://developer.android.com/reference/kotlin/android/app/BackgroundServiceStartNotAllowedException.html#),[ForegroundServiceStartNotAllowedException](https://developer.android.com/reference/kotlin/android/app/ForegroundServiceStartNotAllowedException.html#),[ForegroundServiceTypeException](https://developer.android.com/reference/kotlin/android/app/ForegroundServiceTypeException.html#),[InvalidForegroundServiceTypeException](https://developer.android.com/reference/kotlin/android/app/InvalidForegroundServiceTypeException.html#),[MissingForegroundServiceTypeException](https://developer.android.com/reference/kotlin/android/app/MissingForegroundServiceTypeException.html#) |---------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [BackgroundServiceStartNotAllowedException](https://developer.android.com/reference/kotlin/android/app/BackgroundServiceStartNotAllowedException.html#) | Exception thrown when an app tries to start a background[Service](https://developer.android.com/reference/kotlin/android/app/Service.html#)when it's not allowed to do so. | | [ForegroundServiceStartNotAllowedException](https://developer.android.com/reference/kotlin/android/app/ForegroundServiceStartNotAllowedException.html#) | Exception thrown when an app tries to start a foreground[Service](https://developer.android.com/reference/kotlin/android/app/Service.html#)when it's not allowed to do so. | | [ForegroundServiceTypeException](https://developer.android.com/reference/kotlin/android/app/ForegroundServiceTypeException.html#)                       | Base exception thrown when an app tries to start a foreground[Service](https://developer.android.com/reference/kotlin/android/app/Service.html#)without a valid type.      | | [InvalidForegroundServiceTypeException](https://developer.android.com/reference/kotlin/android/app/InvalidForegroundServiceTypeException.html#)         | Exception thrown when an app tries to start a foreground[Service](https://developer.android.com/reference/kotlin/android/app/Service.html#)with an invalid type.           | | [MissingForegroundServiceTypeException](https://developer.android.com/reference/kotlin/android/app/MissingForegroundServiceTypeException.html#)         | Exception thrown when an app tries to start a foreground[Service](https://developer.android.com/reference/kotlin/android/app/Service.html#)without a type.                 | |

Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation.

## Summary

|                                                                                                                                                                                                                Public constructors                                                                                                                                                                                                                ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException#IllegalStateException())`()` Constructs an IllegalStateException with no detail message.                                                                                                                                                                                                                                                |
| [IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException#IllegalStateException(kotlin.String))`(`s:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Constructs an IllegalStateException with the specified detail message.                                                                                                                                |
| [IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException#IllegalStateException(kotlin.String,%20kotlin.Throwable))`(`message:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `cause:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!`)` Constructs a new exception with the specified detail message and cause. |
| [IllegalStateException](https://developer.android.com/reference/kotlin/java/lang/IllegalStateException#IllegalStateException(kotlin.Throwable))`(`cause:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!`)` Constructs a new exception with the specified cause and a detail message of`(cause==null ? null : cause.toString())`(which typically contains the class and detail message of`cause`).   |

## Public constructors

### IllegalStateException

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

```
IllegalStateException()
```

Constructs an IllegalStateException with no detail message. A detail message is a String that describes this particular exception.  

### IllegalStateException

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

```
IllegalStateException(s: String!)
```

Constructs an IllegalStateException with the specified detail message. A detail message is a String that describes this particular exception.

|                                                             Parameters                                                             ||
|-----|-------------------------------------------------------------------------------------------------------------------------------|
| `s` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:the String that contains a detailed message |

### IllegalStateException

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

```
IllegalStateException(
    message: String!, 
    cause: Throwable!)
```

Constructs a new exception with the specified detail message and cause.

Note that the detail message associated with`cause`is*not*automatically incorporated in this exception's detail message.

|                                                                                                                                                                        Parameters                                                                                                                                                                         ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `message` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:the detail message (which is saved for later retrieval by the[Throwable.getMessage()](https://developer.android.com/reference/kotlin/java/lang/Throwable#getMessage())method).                                                                               |
| `cause`   | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!:the cause (which is saved for later retrieval by the[Throwable.getCause()](https://developer.android.com/reference/kotlin/java/lang/Throwable#getCause())method). (A`null`value is permitted, and indicates that the cause is nonexistent or unknown.) |

### IllegalStateException

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

```
IllegalStateException(cause: Throwable!)
```

Constructs a new exception with the specified cause and a detail message of`(cause==null ? null : cause.toString())`(which typically contains the class and detail message of`cause`). This constructor is useful for exceptions that are little more than wrappers for other throwables (for example, ).

|                                                                                                                                                                       Parameters                                                                                                                                                                        ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `cause` | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!:the cause (which is saved for later retrieval by the[Throwable.getCause()](https://developer.android.com/reference/kotlin/java/lang/Throwable#getCause())method). (A`null`value is permitted, and indicates that the cause is nonexistent or unknown.) |