Agora Java API Reference for Android
Agora High-Level API Reference for All Platforms

.android_src_main_java_io_agora_rtc2_mainpage

Agora provides ensured quality of experience (QoE) for worldwide Internet-based voice and video communications through a virtual global network optimized for real-time web and mobile-to-mobile applications.

Channel management

Method Description
create1 Creates an RtcEngine instance.
create2 Creates an RtcEngine instance and specifies the connection area.
destroy Releases the IRtcEngine object.
setChannelProfile Sets the channel profile.
joinChannel1 Joins a channel.
joinChannel2 Joins a channel with media options.
updateChannelMediaOptions Updates the channel media options after joining a channel.
leaveChannel Leaves the channel.
setClientRole Sets the role of the user.
renewToken Renews the token.
getConnectionState Gets the connection state of the app.

Channel events

Event Description
onJoinChannelSuccess Occurs when the local user successfully joins the specified channel.
onRejoinChannelSuccess Occurs when the local user rejoins the channel after being disconnected dut ro network problems.
onClientRoleChanged Occurs when the user role in a Live-Broadcast channel has switched.
onLeaveChannel Occurs when the local user successfully leaves the channel.
onUserJoined Occurs when a remote user or broadcaster joins the channel.
onUserOffline Occurs when a remote user or broadcaster goes offline.
onConnectionLost Occurs when the SDK cannot reconnect to the server 10 seconds after its connections to the server is interrupted.
onRequestToken Occurs when the token has expired.
onTokenPrivilegeWillExpire Occurs when the token will expire in 30 seconds.

Audio management

Method Description
enableAudio Enables the audio.
disableAudio Disables the audio.
setAudioProfile1 Sets the audio parameters and application scenarios.
setAudioProfile2 Sets the audio profile.
adjustRecordingSignalVolume Adjusts the recording volume.
enableLocalAudio Enables or disables the local audio capture.
muteLocalAudioStream Stops or resumes sending the local audio stream.
muteRemoteAudioStream Stops or resumes receiving the audio stream of a specified user.
muteAllRemoteAudioStreams Stops or resumes receiving all remote audio streams.
setDefaultMuteAllRemoteAudioStreams Determines whether to receive all remote audio streams by default.

Video management

Method Description
enableVideo Enables the video.
disableVideo Disables the video.
startPreview Starts the local video preview before joining a channel.
stopPreview Stops the local video preview.
setupLocalVideo Initializes the local video view.
setupRemoteVideo Initializes the video view of a remote user.
setLocalRenderMode Updates the display mode of the local video view.
setRemoteRenderMode Updates the display mode of the video view of a remote user.
enableLocalVideo Disables or re-enables the local video capture.
muteLocalVideoStream Stops or resumes sending the local video stream.
muteRemoteVideoStream Stops or resumes receiving the video stream of a specified user.
muteAllRemoteVideoStreams Stops or resumes receiving all remote video streams.
setDefaultMuteAllRemoteVideoStreams Determines whether to receive all remote video streams by default.

Local media events

Event Description
onLocalAudioStateChanged Occurs when the local audio state changes.
onLocalVideoStateChanged Occurs when the local video state changes.
onFirstLocalAudioFramePublished Occurs when the first audio frame is published.

Remote media events

Event Description
onRemoteAudioStateChanged Occurs when the remote audio state changes
onRemoteVideoStateChanged Occurs when the remote video state changes

Statistics events

Event Description
onLocalAudioStats Reports the statistics of the local audio.
onRemoteAudioStats Reports the statistics of the remote audio.
onRtcStats Reports the statistics of the current call.
onNetworkQuality Reports the network quality of each user.
onLocalVideoStats Reports the statistics of the local video.
onRemoteVideoStats Reports the statistics of the remote video.

Audio volume indication

Method Description
enableAudioVolumeIndication Enables the onAudioVolumeIndication callback to report on which users are speaking and the speakers' volume.
Event Description
onAudioVolumeIndication Reports which users are speaking and the speaker's volume.

Music file playback and mixing

Method Description
startAudioMixing Starts playing and mixing the music file.
stopAudioMixing Stops playing or mixing the music file.
pauseAudioMixing Pauses playing and mixing the music file.
resumeAudioMixing Resumes playing and mixing the music file.
adjustAudioMixingVolume Adjusts the volume of audio mixing.
getAudioMixingDuration Gets the duration (ms) of the music file.
getAudioMixingCurrentPosition Gets the playback position (ms) of the music file.
setAudioMixingPosition Sets the playback starting position (ms) of the music file.
Event Description
onAudioMixingStateChanged Occurs when the state of the local user's audio mixing file changes.

Audio effect playback

Method Description
getEffectsVolume Gets the volume of the audio effects.
setEffectsVolume Sets the volume of audio effects.
setVolumeOfEffect Sets the volume of the specified audio effect.
playEffect Plays a specified audio effect.
stopEffect Stops playing the specified audio effect.
stopAllEffects Stops playing all audio effects.
preloadEffect Preloads a specified audio effect.
unloadEffect Releases the specific preloaded audio effect from the memory.
unloadAllEffects Releases all preloaded audio effects from the memory.
pauseEffect Pauses playing the specified audio effect.
pauseAllEffects Pauses playing all audio effects.
resumeEffect Resumes playing the specified audio effect.
resumeAllEffects Resumes playing all audio effects.

In-ear monitor

Method Description
enableInEarMonitoring Enables in-ear monitoring.
setInEarMonitoringVolume Sets the volume of the in-ear monitoring.

Last-mile test

Method Description
startLastmileProbeTest Starts the last-mile network probe test.
stopLastmileProbeTest Stops the last-mile network probe test.
Event Description
onLastmileProbeResult Reports the lastmile network probe result.

Dual video stream

Method Description
enableDualStreamMode Enables or disables the dual video stream mode.
setRemoteVideoStreamType Sets the remote video stream type.
setRemoteDefaultVideoStreamType Sets the default stream type of the remote video if the remote user has enabled dual-stream.

Channel media relay

Method Description
startChannelMediaRelay Starts to relay media streams across channels.
stopChannelMediaRelay Stops the media stream relay.
Event Description
onChannelMediaRelayStateChanged Occurs when the state of the media stream relay changes.
onChannelMediaRelayEvent Reports events during the media stream relay.

External audio data

Method Description
setExternalAudioSource Sets the external audio source.
pushExternalAudioFrame Pushes the external audio data to the app.

External video data

Method Description
setExternalVideoSource Sets the external video source.
pushExternalVideoFrame1 Pushes the external video frame to the SDK.
pushExternalVideoFrame2 Pushes the external video frame to the SDK.
pushExternalEncodedVideoFrame Pushes the encoded video image to the app.

Raw Video Data

You can also use the C++ methods for raw video data.

Method Description
registerVideoFrameObserver Registers a video frame observer object.
Event Description
onCaptureVideoFrame Occurs each time The SDK receives a video frame captured by the local camera.
onRenderVideoFrame Occurs each time the SDK receives a video frame sent by the remote user.

Media metadata

This group of methods apply to LIVE_BROADCASTING profile only. Do not implement getMaxMetadataSize, onReadyToSendMetadata, and onMetadataReceived in the IRtcEngineEventHandler class.

Method Description
registerMediaMetadataObserver Registers a media metadata observer object.
Event Description
getMaxMetadataSize Occurs when the SDK requests the maximum size of the metadata.
onReadyToSendMetadata Occurs when the SDK is ready to receive and send metadata.
onMetadataReceived Occurs when the local user receives the metadata.

Stream message

Method Description
createDataStream Creates a data stream.
sendStreamMessage Sends data stream messages.
Event Description
onStreamMessage Occurs when the local user receives a remote data stream within five seconds.
onStreamMessageError Occurs when the local user fails to receive the remote data stream.

Camera control

Method Description
switchCamera Switches between front and rear cameras.

Miscellaneous methods

Method Description
sendCustomReportMessage Reports customized messages.
getCallId Gets the current call ID.
rate Allows a user to rate the call.
complain Allows a user to complain about the call quality.
getSdkVersion Gets the SDK version.
setLogFile Specifies an SDK output log file.
setLogFilter Sets the output log level of the SDK.
setLogLevel Sets the output log level of the SDK.
addHandler Adds the IRtcEngineEventHandler instance.

Miscellaneous events

Method Description
onApiCallExecuted Occurs when an API method is executed.