Aracılığıyla paylaş


AudioManager.RequestAudioFocus Method

Definition

Overloads

RequestAudioFocus(AudioFocusRequestClass)

Request audio focus.

RequestAudioFocus(AudioManager+IOnAudioFocusChangeListener, Stream, AudioFocus)

Request audio focus.

RequestAudioFocus(AudioFocusRequestClass)

Request audio focus.

[Android.Runtime.Register("requestAudioFocus", "(Landroid/media/AudioFocusRequest;)I", "GetRequestAudioFocus_Landroid_media_AudioFocusRequest_Handler", ApiSince=26)]
public virtual Android.Media.AudioFocusRequest RequestAudioFocus (Android.Media.AudioFocusRequestClass focusRequest);
[<Android.Runtime.Register("requestAudioFocus", "(Landroid/media/AudioFocusRequest;)I", "GetRequestAudioFocus_Landroid_media_AudioFocusRequest_Handler", ApiSince=26)>]
abstract member RequestAudioFocus : Android.Media.AudioFocusRequestClass -> Android.Media.AudioFocusRequest
override this.RequestAudioFocus : Android.Media.AudioFocusRequestClass -> Android.Media.AudioFocusRequest

Parameters

focusRequest
AudioFocusRequestClass

a AudioFocusRequest instance used to configure how focus is requested.

Returns

#AUDIOFOCUS_REQUEST_FAILED, #AUDIOFOCUS_REQUEST_GRANTED or #AUDIOFOCUS_REQUEST_DELAYED. <br>Note that the return value is never #AUDIOFOCUS_REQUEST_DELAYED when focus is requested without building the AudioFocusRequest with AudioFocusRequest.Builder#setAcceptsDelayedFocusGain(boolean) set to true.

Attributes

Remarks

Request audio focus. See the AudioFocusRequest for information about the options available to configure your request, and notification of focus gain and loss.

Java documentation for android.media.AudioManager.requestAudioFocus(android.media.AudioFocusRequest).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

RequestAudioFocus(AudioManager+IOnAudioFocusChangeListener, Stream, AudioFocus)

Request audio focus.

[Android.Runtime.Register("requestAudioFocus", "(Landroid/media/AudioManager$OnAudioFocusChangeListener;II)I", "GetRequestAudioFocus_Landroid_media_AudioManager_OnAudioFocusChangeListener_IIHandler")]
public virtual Android.Media.AudioFocusRequest RequestAudioFocus (Android.Media.AudioManager.IOnAudioFocusChangeListener? l, Android.Media.Stream streamType, Android.Media.AudioFocus durationHint);
[<Android.Runtime.Register("requestAudioFocus", "(Landroid/media/AudioManager$OnAudioFocusChangeListener;II)I", "GetRequestAudioFocus_Landroid_media_AudioManager_OnAudioFocusChangeListener_IIHandler")>]
abstract member RequestAudioFocus : Android.Media.AudioManager.IOnAudioFocusChangeListener * Android.Media.Stream * Android.Media.AudioFocus -> Android.Media.AudioFocusRequest
override this.RequestAudioFocus : Android.Media.AudioManager.IOnAudioFocusChangeListener * Android.Media.Stream * Android.Media.AudioFocus -> Android.Media.AudioFocusRequest

Parameters

l
AudioManager.IOnAudioFocusChangeListener

the listener to be notified of audio focus changes

streamType
Stream

the main audio stream type affected by the focus request

durationHint
AudioFocus

use AudiofocusGainTransient to indicate this focus request is temporary, and focus will be abandonned shortly. Examples of transient requests are for the playback of driving directions, or notifications sounds. Use AudiofocusGainTransientMayDuck to indicate also that it's ok for the previous focus owner to keep playing if it ducks its audio output. Alternatively use AudiofocusGainTransientExclusive for a temporary request that benefits from the system not playing disruptive sounds like notifications, for usecases such as voice memo recording, or speech recognition. Use AudiofocusGain for a focus request of unknown duration such as the playback of a song or a video.

Returns

#AUDIOFOCUS_REQUEST_FAILED, #AUDIOFOCUS_REQUEST_GRANTED or #AUDIOFOCUS_REQUEST_DELAYED. <br>Note that the return value is never #AUDIOFOCUS_REQUEST_DELAYED when focus is requested without building the AudioFocusRequest with AudioFocusRequest.Builder#setAcceptsDelayedFocusGain(boolean) set to true.

Attributes

Remarks

Java documentation for android.media.AudioManager.requestAudioFocus(android.media.AudioFocusRequest).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to