MidiManager

class MidiManager
kotlin.Any
   ↳ android.media.midi.MidiManager

This class is the public application interface to the MIDI service.
Requires the PackageManager#FEATURE_MIDI feature which can be detected using PackageManager.hasSystemFeature(String).
Requires API level 23 (Android 6.0, Marshmallow)

Summary

Nested classes

Callback class used for clients to receive MIDI device added and removed notifications
Requires API level 23 (Android 6.0, Marshmallow)

abstract

Listener class used for receiving the results of #openDevice and #openBluetoothDevice
Requires API level 23 (Android 6.0, Marshmallow)

Public methods
Unit

Registers a callback to receive notifications when MIDI devices are added and removed.

Unit

Unregisters a DeviceCallback.

Unit

Opens a MIDI device for reading and writing.

Unit

Opens a Bluetooth MIDI device for reading and writing.

Array<MidiDeviceInfo!>!

Gets the list of all connected MIDI devices.

Public methods

registerDeviceCallback

added in API level 23
fun registerDeviceCallback(callback: MidiManager.DeviceCallback!, handler: Handler!): Unit

Registers a callback to receive notifications when MIDI devices are added and removed. The DeviceCallback#onDeviceStatusChanged method will be called immediately for any devices that have open ports. This allows applications to know which input ports are already in use and, therefore, unavailable. Applications should call #getDevices before registering the callback to get a list of devices already added.
Requires API level 23 (Android 6.0, Marshmallow)

Parameters
callback MidiManager.DeviceCallback!: a DeviceCallback for MIDI device notifications
handler MidiManager.DeviceCallback!: The Handler that will be used for delivering the device notifications. If handler is null, then the thread used for the callback is unspecified.

unregisterDeviceCallback

added in API level 23
fun unregisterDeviceCallback(callback: MidiManager.DeviceCallback!): Unit

Unregisters a DeviceCallback.
Requires API level 23 (Android 6.0, Marshmallow)

Parameters
callback MidiManager.DeviceCallback!: a DeviceCallback to unregister

openDevice

added in API level 23
fun openDevice(deviceInfo: MidiDeviceInfo!, listener: MidiManager.OnDeviceOpenedListener!, handler: Handler!): Unit

Opens a MIDI device for reading and writing.
Requires API level 23 (Android 6.0, Marshmallow)

Parameters
deviceInfo MidiDeviceInfo!: a android.media.midi.MidiDeviceInfo to open
listener MidiDeviceInfo!: a MidiManager.OnDeviceOpenedListener to be called to receive the result
handler MidiDeviceInfo!: the Handler that will be used for delivering the result. If handler is null, then the thread used for the listener is unspecified.

openBluetoothDevice

added in API level 23
fun openBluetoothDevice(bluetoothDevice: BluetoothDevice!, listener: MidiManager.OnDeviceOpenedListener!, handler: Handler!): Unit

Opens a Bluetooth MIDI device for reading and writing.
Requires API level 23 (Android 6.0, Marshmallow)

Parameters
bluetoothDevice BluetoothDevice!: a android.bluetooth.BluetoothDevice to open as a MIDI device
listener BluetoothDevice!: a MidiManager.OnDeviceOpenedListener to be called to receive the result
handler BluetoothDevice!: the Handler that will be used for delivering the result. If handler is null, then the thread used for the listener is unspecified.

getDevices

added in API level 23
fun getDevices(): Array<MidiDeviceInfo!>!

Gets the list of all connected MIDI devices.
Requires API level 23 (Android 6.0, Marshmallow)

Return
Array<MidiDeviceInfo!>!: an array of all MIDI devices