Android Marshmallow gives us good audio, video, and camera capabilities, and you can see that improvements have been made to enable and better support new or mint condition protocols or even change the behavior of some APIs, such as the camera service.

Audio features

Android Marshmallow 6.0 adds some enrichments to the audio features that we will cover in the upcoming sections.

Support for the MIDI protocol

The package was added in Android 6.0 (API 23).

With the new midi APIs, you can now send and receive MIDI (short for Musical Instrument Digital Interface) events in a much simpler way than earlier.

The package was built to provide us with capabilities to do the following:

  • Connect and use a MIDI keyboard
  • Connect to other MIDI controllers
  • Use external MIDI synthesizers, external peripherals, lights, show control, and so on
  • Allow dynamic music generation from games or music-creation apps
  • Allow the creation and passing of MIDI messages between apps
  • Allow Android devices to act as multi-touch controllers when connected to a laptop

When dealing with MIDI, you must declare it in the manifest, as follows:

<uses-feature android:name="" android:required="true"/>

Pay attention to the required part; in a manner similar to other features, setting it to true will make your app visible in the play store only if the device supports the MIDI API.

You can also check in runtime for MIDI support and then change the required part to false:

PackageManager pkgMgr = context.getPackageManager();
if (pkgMgr.hasSystemFeature(PackageManager.FEATURE_MIDI)) {
  //we can use MIDI API here as we know the device supports the MIDI API.


A way to properly use the MIDI API is via the MidiManager class; obtain it via context and use it when required:

MidiManager midiMgr = (MidiManager)context.getSystemService(Context.MIDI_SERVICE);

For more information, you can refer to:

Digital audio capture and playback

Two new classes have been added for digital audio capture and playback:

  • – digital audio capture
  • – digital audio playback

These will help configure the audio source and sink properties.

Audio and input devices

The new hasMicrophone() method has been added to the InputDevice class. This will report whether the device has a built-in microphone that developers can use. Let’s say you want to enable voice search from a controller connected to Android TV and you get an onSearchRequested() callback for the user’s search. You can then verify that there’s a microphone with the inputDevice object you get in the callback.

Information on audio devices

The new AudioManager.getDevices(int flags) method allows easy retrieval of all the audio devices currently connected to the system. If you want to be notified when there are audio device connections/disconnections, you can register your app to an AudioDeviceCallback callback via the AudioManager.registerAudioDeviceCallback(AudioDeviceCallback callback, Handler handler) method.

Changes in AudioManager

Some changes have been introduced in the AudioManager class, and they are as follows:

  • Using AudioManager to set the volume directly is not supported.
  • Using AudioManager to mute specific streams is not supported.
  • The AudioManager.setStreamSolo(int streamType, boolean state) method is deprecated. If you need exclusive audio playback, use AudioManager.requestAudioFocus(AudioManager.OnAudioFocusChangeListener l, int streamType, int durationHint).
  • The AudioManager.setStreamMute(int streamType, boolean state) method is deprecated. If you need to use AudioManager.adjustStreamVolume(int streamType, int direction, int flags) for direction, you can use one of the newly added constants.
  • ADJUST_MUTE will mute the volume. Note that it has no effect if the stream is already muted.
  • ADJUST_UNMUTE will unmute the volume. Note that it has no effect if the stream is not muted.