Skip to content

Most visited

Recently visited

navigation

AudioRouting

public interface AudioRouting

android.media.AudioRouting
Known Indirect Subclasses


AudioRouting defines an interface for controlling routing and routing notifications in AudioTrack and AudioRecord objects.

Summary

Nested classes

interface AudioRouting.OnRoutingChangedListener

Defines the interface by which applications can receive notifications of routing changes for the associated AudioRouting

Public methods

abstract void addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener, Handler handler)

Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this AudioTrack/AudioRecord.

abstract AudioDeviceInfo getPreferredDevice()

Returns the selected output/input specified by setPreferredDevice(AudioDeviceInfo).

abstract AudioDeviceInfo getRoutedDevice()

Returns an AudioDeviceInfo identifying the current routing of this AudioTrack/AudioRecord.

abstract void removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener)

Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.

abstract boolean setPreferredDevice(AudioDeviceInfo deviceInfo)

Specifies an audio device (via an AudioDeviceInfo object) to route the output/input to/from.

Public methods

addOnRoutingChangedListener

added in API level 24
void addOnRoutingChangedListener (AudioRouting.OnRoutingChangedListener listener, 
                Handler handler)

Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this AudioTrack/AudioRecord.

Parameters
listener AudioRouting.OnRoutingChangedListener: The AudioRouting.OnRoutingChangedListener interface to receive notifications of rerouting events.

handler Handler: Specifies the Handler object for the thread on which to execute the callback. If null, the Handler associated with the main Looper will be used.

getPreferredDevice

added in API level 24
AudioDeviceInfo getPreferredDevice ()

Returns the selected output/input specified by setPreferredDevice(AudioDeviceInfo). Note that this is not guaranteed to correspond to the actual device being used for playback/recording.

Returns
AudioDeviceInfo

getRoutedDevice

added in API level 24
AudioDeviceInfo getRoutedDevice ()

Returns an AudioDeviceInfo identifying the current routing of this AudioTrack/AudioRecord. Note: The query is only valid if the AudioTrack/AudioRecord is currently playing. If it is not, getRoutedDevice() will return null.

Returns
AudioDeviceInfo

removeOnRoutingChangedListener

added in API level 24
void removeOnRoutingChangedListener (AudioRouting.OnRoutingChangedListener listener)

Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.

Parameters
listener AudioRouting.OnRoutingChangedListener: The previously added AudioRouting.OnRoutingChangedListener interface to remove.

setPreferredDevice

added in API level 24
boolean setPreferredDevice (AudioDeviceInfo deviceInfo)

Specifies an audio device (via an AudioDeviceInfo object) to route the output/input to/from.

Parameters
deviceInfo AudioDeviceInfo: The AudioDeviceInfo specifying the audio sink or source. If deviceInfo is null, default routing is restored.

Returns
boolean true if succesful, false if the specified AudioDeviceInfo is non-null and does not correspond to a valid audio device.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.