# MidiDevice.MidiConnection

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

# MidiConnection

*** ** * ** ***

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

```
class MidiConnection : Closeable
```

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

This class represents a connection between the output port of one device and the input port of another. Created by[connectPorts](https://developer.android.com/reference/kotlin/android/media/midi/MidiDevice#connectPorts(android.media.midi.MidiInputPort,%20kotlin.Int)). Close this object to terminate the connection.

## Summary

|                                                                                              Public methods                                                                                               ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [close](https://developer.android.com/reference/kotlin/android/media/midi/MidiDevice.MidiConnection#close())`()` <br /> |

|                                                                                                Protected methods                                                                                                ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [finalize](https://developer.android.com/reference/kotlin/android/media/midi/MidiDevice.MidiConnection#finalize())`()` <br /> |

## Public methods

### close

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

```
open fun close(): Unit
```

|                        Exceptions                        ||
|-----------------------|-----------------------------------|
| `java.lang.Exception` | if this resource cannot be closed |
| `java.io.IOException` | if an I/O error occurs            |

## Protected methods

### finalize

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

```
protected open fun finalize(): Unit
```

|                         Exceptions                         ||
|-----------------------|-------------------------------------|
| `java.lang.Throwable` | the`Exception`raised by this method |