Stay organized with collections
Save and categorize content based on your preferences.
MicrophoneDirection
public
interface
MicrophoneDirection
android.media.MicrophoneDirection
|
Known indirect subclasses
AudioRecord |
The AudioRecord class manages the audio resources for Java applications
to record audio from the audio input hardware of the platform.
|
MediaRecorder |
Used to record audio and video.
|
|
Interface defining mechanism for controlling the directionality and field width of
audio capture.
Summary
Constants
MIC_DIRECTION_AWAY_FROM_USER
public static final int MIC_DIRECTION_AWAY_FROM_USER
Optimize capture for audio coming from the side of the device pointing away from the user.
In the typical case, a device with a single screen, screen-side camera/microphone and
non-screen-side camera/microphone, this will be the non-screen side.
For a different device geometry, it is the side for which the expectation is to be
facing away from the user. This is the "taking a video of something else" case.
Constant Value:
2
(0x00000002)
MIC_DIRECTION_EXTERNAL
public static final int MIC_DIRECTION_EXTERNAL
Optimize capture for audio coming from an off-device microphone.
Constant Value:
3
(0x00000003)
MIC_DIRECTION_TOWARDS_USER
public static final int MIC_DIRECTION_TOWARDS_USER
Optimize capture for audio coming from the side of the device facing the user.
In the typical case, a device with a single screen, screen-side camera/microphone and
non-screen-side camera/microphone, this will be the screen side (as in a "selfie").
For a different device geometry, it is the side for which the expectation is to be
facing the user.
Constant Value:
1
(0x00000001)
MIC_DIRECTION_UNSPECIFIED
public static final int MIC_DIRECTION_UNSPECIFIED
Don't do any directionality processing of the activated microphone(s).
Constant Value:
0
(0x00000000)
Public methods
setPreferredMicrophoneDirection
public abstract boolean setPreferredMicrophoneDirection (int direction)
Specifies the logical microphone (for processing). Applications can use this to specify
which side of the device to optimize capture from. Typically used in conjunction with
the camera capturing video.
Usage would include specifying the audio capture to follow camera being used to capture
video.
Returns |
boolean |
true if sucessful. |
setPreferredMicrophoneFieldDimension
public abstract boolean setPreferredMicrophoneFieldDimension (float zoom)
Specifies the zoom factor (i.e. the field dimension) for the selected microphone
(for processing). The selected microphone is determined by the use-case for the stream.
Usage would include specifying the audio focus to follow the zoom specified for the camera
being used to capture video.
Parameters |
zoom |
float : the desired field dimension of microphone capture. Range is from -1 (wide angle),
though 0 (no zoom) to 1 (maximum zoom).
Value is between -1.0f and 1.0f inclusive |
Returns |
boolean |
true if sucessful. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[],null,["# MicrophoneDirection\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Constants](#constants) \\| [Methods](#pubmethods) \n\nMicrophoneDirection\n===================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/media/MicrophoneDirection \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nMicrophoneDirection\n`\n\n\n`\n\n\n`\n\n|-----------------------------------|\n| android.media.MicrophoneDirection |\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [AudioRecord](/reference/android/media/AudioRecord), [MediaRecorder](/reference/android/media/MediaRecorder) |---------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------| | [AudioRecord](/reference/android/media/AudioRecord) | The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform. | | [MediaRecorder](/reference/android/media/MediaRecorder) | Used to record audio and video. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface defining mechanism for controlling the directionality and field width of\naudio capture.\n\nSummary\n-------\n\n| ### Constants ||\n|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `int` | [MIC_DIRECTION_AWAY_FROM_USER](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_AWAY_FROM_USER) Optimize capture for audio coming from the side of the device pointing away from the user. |\n| `int` | [MIC_DIRECTION_EXTERNAL](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_EXTERNAL) Optimize capture for audio coming from an off-device microphone. |\n| `int` | [MIC_DIRECTION_TOWARDS_USER](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_TOWARDS_USER) Optimize capture for audio coming from the side of the device facing the user. |\n| `int` | [MIC_DIRECTION_UNSPECIFIED](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_UNSPECIFIED) Don't do any directionality processing of the activated microphone(s). |\n\n| ### Public methods ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[setPreferredMicrophoneDirection](/reference/android/media/MicrophoneDirection#setPreferredMicrophoneDirection(int))`(int direction) ` Specifies the logical microphone (for processing). |\n| ` abstract boolean` | ` `[setPreferredMicrophoneFieldDimension](/reference/android/media/MicrophoneDirection#setPreferredMicrophoneFieldDimension(float))`(float zoom) ` Specifies the zoom factor (i.e. |\n\nConstants\n---------\n\n### MIC_DIRECTION_AWAY_FROM_USER\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int MIC_DIRECTION_AWAY_FROM_USER\n```\n\nOptimize capture for audio coming from the side of the device pointing away from the user.\nIn the typical case, a device with a single screen, screen-side camera/microphone and\nnon-screen-side camera/microphone, this will be the non-screen side.\nFor a different device geometry, it is the side for which the expectation is to be\nfacing away from the user. This is the \"taking a video of something else\" case.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n2\n(0x00000002)\n\n\n### MIC_DIRECTION_EXTERNAL\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int MIC_DIRECTION_EXTERNAL\n```\n\nOptimize capture for audio coming from an off-device microphone.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n3\n(0x00000003)\n\n\n### MIC_DIRECTION_TOWARDS_USER\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int MIC_DIRECTION_TOWARDS_USER\n```\n\nOptimize capture for audio coming from the side of the device facing the user.\nIn the typical case, a device with a single screen, screen-side camera/microphone and\nnon-screen-side camera/microphone, this will be the screen side (as in a \"selfie\").\nFor a different device geometry, it is the side for which the expectation is to be\nfacing the user.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n1\n(0x00000001)\n\n\n### MIC_DIRECTION_UNSPECIFIED\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int MIC_DIRECTION_UNSPECIFIED\n```\n\nDon't do any directionality processing of the activated microphone(s).\n\n\u003cbr /\u003e\n\nConstant Value:\n\n0\n(0x00000000)\n\n\nPublic methods\n--------------\n\n### setPreferredMicrophoneDirection\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean setPreferredMicrophoneDirection (int direction)\n```\n\nSpecifies the logical microphone (for processing). Applications can use this to specify\nwhich side of the device to optimize capture from. Typically used in conjunction with\nthe camera capturing video.\n\nUsage would include specifying the audio capture to follow camera being used to capture\nvideo.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `direction` | `int`: Direction constant. Value is [MIC_DIRECTION_UNSPECIFIED](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_UNSPECIFIED), [MIC_DIRECTION_TOWARDS_USER](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_TOWARDS_USER), [MIC_DIRECTION_AWAY_FROM_USER](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_AWAY_FROM_USER), or [MIC_DIRECTION_EXTERNAL](/reference/android/media/MicrophoneDirection#MIC_DIRECTION_EXTERNAL) \u003cbr /\u003e |\n\n| Returns ||\n|-----------|---------------------------|\n| `boolean` | true if sucessful. \u003cbr /\u003e |\n\n### setPreferredMicrophoneFieldDimension\n\nAdded in [API level 29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean setPreferredMicrophoneFieldDimension (float zoom)\n```\n\nSpecifies the zoom factor (i.e. the field dimension) for the selected microphone\n(for processing). The selected microphone is determined by the use-case for the stream.\n\nUsage would include specifying the audio focus to follow the zoom specified for the camera\nbeing used to capture video.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `zoom` | `float`: the desired field dimension of microphone capture. Range is from -1 (wide angle), though 0 (no zoom) to 1 (maximum zoom). Value is between -1.0f and 1.0f inclusive \u003cbr /\u003e |\n\n| Returns ||\n|-----------|---------------------------|\n| `boolean` | true if sucessful. \u003cbr /\u003e |"]]