This topic describes the callback functions for the audio and video call API for Android.
Callback type | Function | Description |
Global error event | void onError(int errorCode, String errorMessage, Bundle extra ); | This callback is triggered when a non-recoverable software development kit (SDK) error occurs. Your application must listen for this callback to provide appropriate UI prompts. This callback reports only global errors, not errors related to publishing or subscribing. |
Channel events | void onRoomInfo( RoomInfo info ); | This callback is invoked when a channel is successfully created. It contains the channel information. If channel creation fails, the onError callback returns the corresponding error. |
void onEnterRoom( int result ); | This callback is invoked when a user joins a channel. A value of 0 indicates success. A non-zero value indicates failure. For more information, see Error codes. | |
void onLeaveRoom( int result ); | This callback is invoked when a user leaves a channel. A value of 0 indicates success. A non-zero value indicates failure. For more information, see Error codes. | |
void onRecordInfo( String recordId ) | This callback returns the recording result, which includes a recording ID. You can use this ID to perform operations on the recording file using other query interfaces. | |
Preview events | void onCameraPreviewInfo(ARTVCView view ); | This callback is invoked when the preview starts successfully. It returns a view that you can add to your UI for display. If the preview fails, the onError callback returns an error message. |
void onCameraPreviewFirstFrame(); | This callback is invoked when the first frame of the preview is rendered. | |
void onCameraPreviewStop(); | This callback is invoked when the preview stops. | |
Publish and subscribe events | void onPublishEvent(PublishConfig config, PublishEventCode eventCode, String eventDetail, FeedInfo feedInfo ); | This callback notifies you of publishing events. The results of calling the publish interface are returned through this callback. |
void onUnpublishEvent( UnpublishConfig config, PublishEventCode eventCode, String eventDetail ); | This callback notifies you of unpublishing events. The results of calling the unpublish interface are returned through this callback. | |
void onSubscribeEvent(FeedInfo feedInfo, SubscribeEventCode eventCode, String eventDetail, ARTVCView view ); | This callback notifies you of subscription events. The results of calling the subscribe interface are returned through this callback. The view for video rendering is returned in a subsequent callback for the first frame of data. | |
void onUnsubscribeEvent( FeedInfo feedInfo, SubscribeEventCode eventCode, String eventDetail ); | This callback notifies you of unsubscription events. When a user calls the unsubscribe interface to unsubscribe from a media stream, the results are returned through this callback. | |
Channel member events | void onParticipantsEnter( List infos ); | This callback notifies users in a channel when a new user joins. The new user's information is sent to all other users in the channel. The new user also receives information about the existing members through this callback. |
void onParticipantsLeave(List<ParticipantLeaveInfo>uidList ); | This callback notifies users in a channel when another user leaves. This information is sent to all remaining users in the channel. | |
void onPublishNotify(FeedInfo publisherInfo ); | New user-published notifications. | |
void onUnpublishNotify(FeedInfo publisherInfo ); | The published notification was canceled by the user. | |
void onSubscribeNotify(FeedInfo publisherInfo, ParticipantInfo subscriberInfo ); | Your notification subscriptions. | |
void onUnsubscribeNotify(FeedInfo publisherInfo, ParticipantInfo subscribeInfo ); | User unsubscribe notification. | |
Video rendering start events | void onRemoteViewFirstFrame( FeedInfo publisherInfo, ARTVCView view ); | This callback notifies users when a subscribed video stream starts rendering. |
void onRemoteViewStop( FeedInfo feedInfo, ARTVCView view ); | This callback notifies users when a subscribed video stream stops rendering. | |
Current network status | void onCurrentNetworkType( int type ); | This callback reports the current network status of the device. When the network status changes, your application is notified through this callback. When you set the global callback listener using the |
void onBandwidthImportanceChangeNotify( boolean isLow, double currentBandwidth, FeedInfo feedInfo ); | This callback provides notifications about bandwidth changes. It is invoked when the bandwidth changes from normal to poor, or from poor back to normal. | |
Current audio output mode | void onCurrentAudioPlayoutMode( int mode ); | This callback reports the current audio output mode of the device. When the audio output mode changes, your application is notified through this callback. When you set the global callback listener using the |
Frame capture result callback | void onSnapShotComplete( Bitmap image, FeedInfo feedInfo ); | After a frame is captured, this callback is invoked to return the result. |
Debug information callbacks | void onStatisticDebugInfo(StatisticInfoForDebug infoForDebug, FeedInfo feedInfo ); | Debugging statistics. |
void onRealTimeStatisticInfo( RealTimeStatisticReport report, FeedInfo feedInfo ); | Debug real-time quality. | |
Text interaction callbacks | void onMsgReceive(Msg4Receive msg4Receive); | A text message is accepted. For more information, see Important Parameters. |
void onMsgSend( int error, String errorMessage, long msgId ); | Message sending result. | |
Invitation interaction callbacks | void onInviteResponse( String inviteTaskId, int code, String msg ); | This callback returns the result of sending an invitation. A code value of 0 indicates success. In |
void onReplyResponse( String inviteTaskId, int code, String msg ); | This callback returns the result of replying to an invitation. A code value of 0 indicates success. In | |
void onReplyOfInviteNotify(ReplyOfInviteInfo replyInfo ); | After an invitation is sent, this callback returns the recipient's reply, such as accept or reject. For more information, see Important parameters. In | |
Custom stream ingest local preview view interaction callbacks | void onCustomPublishPreviewInfo(PublishVideoSource videoSource, ARTVCView view ); | This callback returns the local preview view for custom stream ingest. The video source is identified by videoSource. In |
void onCustomPublishPreviewFirstFrame( PublishVideoSource videoSource ); | This event is triggered when the first frame of the local preview for custom stream ingest is displayed. The video source is identified by videoSource. In | |
void onCustomPublishPreviewStop( PublishVideoSource videoSource ); | This event is triggered when the local preview for custom stream ingest stops. The video source is identified by videoSource. In |
onError
Declaration:
void onError(int errorCode, String errorMessage, Bundle extra );Description: This callback is triggered when a non-recoverable SDK error occurs. Your application must listen for this callback to provide appropriate UI prompts based on the error. This callback reports only global errors. It does not report errors that occur during publishing or subscribing.
Parameters:
Parameter
Type
Description
errorCode
int
The error code. For more information, see Error codes.
errorMessage
String
The error message.
extra
Bundle
An extension field. Some error codes may include extra information to help you locate the problem.
Return value: None.
onRoomInfo
Declaration:
void onRoomInfo( RoomInfo info );Description: This callback is invoked when a channel is successfully created. It contains the channel information. If channel creation fails, the onError callback returns the corresponding error.
Parameters:
Parameter
Type
Description
info
RoomInfo
Room information. For more information, see Important parameters.
Return value: None.
onEnterRoom
Declaration:
void onEnterRoom( int result );Description: This callback is invoked when a user joins a channel. A value of 0 indicates success. A non-zero value indicates failure. For more information, see Error codes.
Parameters:
Parameter
Type
Description
result
int
The result. A value of 0 indicates success. A non-zero value indicates failure. For more information, see Error codes.
Return value: None.
onLeaveRoom
Declaration:
void onLeaveRoom( int result );Description: This callback is invoked when a user leaves a channel. A value of 0 indicates success. A non-zero value indicates failure. For more information, see Error codes.
Parameters:
Parameter
Type
Description
result
int
The result. A value of 0 indicates success. A non-zero value indicates failure. For more information, see Error codes.
Return value: None.
onRecordInfo
Declaration:
void onRecordInfo( String recordId );Description: This callback returns the recording result, which includes a recording ID. You can use this ID to perform operations on the recording file using other query interfaces.
Parameters:
Parameter
Type
Description
recordId
String
The recording ID.
Return value: None.
onCameraPreviewInfo
Declaration:
void onCameraPreviewInfo(ARTVCView view );Description: This callback is invoked when the preview starts successfully. It returns a view that you can add to your UI for display. If the preview fails, the onError callback returns an error message.
Parameters:
Parameter
Type
Description
view
ARTVCView
The video rendering control.
Return value: None.
onCameraPreviewFirstFrame
Declaration:
void onCameraPreviewFirstFrame();Description: This callback is invoked when the first frame of the preview is rendered.
Parameters: None.
Return value: None.
onCameraPreviewStop
Declaration:
void onCameraPreviewStop();Description: This callback is invoked when the preview stops.
Parameters: None.
Return value: None.
onPublishEvent
Declaration:
void onPublishEvent(PublishConfig config, PublishEventCode eventCode, String eventDetail, FeedInfo feedInfo );Description: This callback notifies you of publishing events. The results of calling the publish interface are returned through this callback.
Parameters:
Parameter
Type
Description
config
PublishConfig
The configuration information for this publishing operation.
eventCode
PublishEventCode
The event code. For more information, see Important parameters.
eventDetail
String
The event information.
feedInfo
FeedInfo
If the stream can be published, this parameter returns the feedInfo information for the published stream. The feedInfo information is returned only when eventCode is PUBLISH_START. In other cases, null is returned.
Return value: None.
onUnpublishEvent
Declaration:
void onUnpublishEvent( UnpublishConfig config, PublishEventCode eventCode, String eventDetail );Description: This callback notifies you of unpublishing events. The results of calling the unpublish interface are returned through this callback.
Parameters:
Parameter
Type
Description
config
UnpublishConfig
The configuration information for this unpublishing operation.
eventCode
PublishEventCode
The event code. For more information, see Important parameters.
eventDetail
String
The event information.
Return value: None.
onSubscribeEvent
Declaration:
void onSubscribeEvent(FeedInfo feedInfo, SubscribeEventCode eventCode, String eventDetail, ARTVCView view );Description: This callback notifies you of subscription events. The results of calling the subscribe interface are returned through this callback. The view for video rendering is returned in a subsequent callback for the first frame of data.
Parameters:
Parameter
Type
Description
feedInfo
FeedInfo
The publisher information for the subscribed stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
eventCode
SubscribeEventCode
The event code. For more information, see Important parameters.
eventDetail
String
The event information.
view
ARTVCView
This parameter is null.
Return value: None.
onUnsubscribeEvent
Declaration:
void onUnsubscribeEvent( FeedInfo feedInfo, SubscribeEventCode eventCode, String eventDetail );Description: This callback notifies you of unsubscription events. When a user calls the unsubscribe interface to unsubscribe from a media stream, the results are returned through this callback.
Parameters:
Parameter
Type
Description
feedInfo
FeedInfo
The publisher information for the subscribed stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
eventCode
SubscribeEventCode
The event code. For more information, see Important parameters.
eventDetail
String
The event information.
Return value: None.
onParticipantsEnter
Declaration:
void onParticipantsEnter( List infos );Description: This callback notifies users in a channel when a new user joins. The new user's information is sent to all other users in the channel. The new user also receives information about the existing members through this callback.
Parameters:
Parameter
Type
Description
infos
List
An array of member information. Each member object contains the member ID, all published streams of the member, and all subscribed streams of the member. For more information, see Important parameters.
Return value: None.
onParticipantsLeave
Declaration:
void onParticipantsLeave( List<ParticipantLeaveInfo> uidList);Description: This callback notifies users in a channel when another user leaves. This information is sent to all remaining users in the channel.
Parameters:
Parameter
Type
Description
uidList
List<ParticipantLeaveInfo>
An array of member UID information.
Return value: None.
onPublishNotify
Declaration:
void onPublishNotify(FeedInfo publisherInfo );Note: These are new notifications that the user published.
Parameters:
Parameter
Type
Description
publisherInfo
FeedInfo
Information about the newly published stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
Return value: None.
onUnpublishNotify
Declaration:
void onUnpublishNotify(FeedInfo publisherInfo );Note: The user has unpublished the notification.
Parameters:
Parameter
Type
Description
publisherInfo
FeedInfo
Information about the unpublished stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
Return value: None.
onSubscribeNotify
Declaration:
void onSubscribeNotify(FeedInfo publisherInfo, ParticipantInfo subscriberInfo );Note: These are the notifications that you have subscribed to.
Parameters:
Parameter
Type
Description
publisherInfo
FeedInfo
The publisher information for the subscribed stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
subscriberInfo
ParticipantInfo
The information of the subscriber.
Return value: None.
onUnsubscribeNotify
Declaration:
void onUnsubscribeNotify(FeedInfo publisherInfo, ParticipantInfo subscribeInfo );Note: A notification indicating that a user has unsubscribed.
Parameters:
Parameter
Type
Description
publisherInfo
FeedInfo
The publisher information for the subscribed stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
subscribeInfo
ParticipantInfo
The information of the subscriber.
Return value: None.
onRemoteViewFirstFrame
Declaration:
void onRemoteViewFirstFrame(FeedInfo publisherInfo);Description: This callback notifies users when a subscribed video stream starts rendering.
Parameters:
Parameter
Type
Description
publisherInfo
FeedInfo
The publisher information for the subscribed stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
Return value: None.
onRemoteViewStop
Declaration:
void onRemoteViewStop( FeedInfo feedInfo, ARTVCView view );Description: This callback notifies users when a subscribed video stream stops rendering.
Parameters:
Parameter
Type
Description
feedInfo
FeedInfo
The publisher information for the subscribed stream. This includes the publisher ID and the corresponding stream ID. For more information, see Important parameters.
view
ARTVCView
The corresponding view for video rendering.
Return value: None.
onCurrentNetworkType
Declaration:
void onCurrentNetworkType( int type );Description: This callback reports the current network status of the device. When the network status changes, your application is notified through this callback. When you set the global callback listener using the
setRtcListenerAndHandlerinterface, this callback also notifies your application of the current network type.Parameters:
Parameter
Type
Description
type
int
The network status:
0: No network is available.
1: Wi-Fi network.
2: Mobile network. On a mobile network, your application should notify users that data charges may apply.
Return value: None.
onBandwidthImportanceChangeNotify
Declaration:
void onBandwidthImportanceChangeNotify( boolean isLow, double currentBandwidth, FeedInfo feedInfo );Description: This callback provides notifications about bandwidth changes. It is invoked when the bandwidth changes from normal to poor, or from poor back to normal.
Parameters:
Parameter
Type
Description
isLow
boolean
Indicates whether the network condition is poor.
currentBandwidth
double
The current effective bandwidth.
feedInfo
FeedInfo
The stream information corresponding to the bandwidth change.
Return value: None.
onCurrentAudioPlayoutMode
Declaration:
void onCurrentAudioPlayoutMode( int mode );Description: This callback reports the current audio output mode of the device. When the audio output mode changes, your application is notified through this callback. When you set the global callback listener using the
setRtcListenerAndHandlerinterface, this callback also notifies your application of the current audio output mode.Parameters:
Parameter
Type
Description
mode
int
The audio output mode:
1: EARPIECE, earpiece output.
2: SPEAKERPHONE, speakerphone output.
3: WIREDHEADSET, wired headset output.
4: BLUETOOTH, Bluetooth output.
5: NONE, no output.
Return value: None.
onSnapShotComplete
Declaration:
void onSnapShotComplete( Bitmap image, FeedInfo feedInfo );Description: After a frame is captured, this callback is invoked to return the result.
Parameters:
Parameter
Type
Description
image
Bitmap
The captured image.
feedInfo
FeedInfo
The stream information for the captured frame. This can be a remote or local stream.
Return value: None.
onStatisticDebugInfo
Declaration:
void onStatisticDebugInfo( StatisticInfoForDebug infoForDebug, FeedInfo feedInfo );Description: Provides debugging statistics.
Parameters:
Parameter
Type
Description
infoForDebug
StatisticInfoForDebug
The statistics. For more information, see Important parameters.
feedInfo
FeedInfo
The corresponding stream information. This can be a remote or local stream.
Return value: None.
onRealTimeStatisticInfo
Declaration:
void onRealTimeStatisticInfo( RealTimeStatisticReport report, FeedInfo feedInfo );Description: Provides real-time quality information for debugging.
Parameters:
Parameter
Type
Description
report
RealTimeStatisticReport
The real-time quality information. For more information, see Important parameters.
feedInfo
FeedInfo
The corresponding stream information. This can be a remote or local stream.
Return value: None.
onMsgReceive
Declaration:
void onMsgReceive(Msg4Receive msg4Receive);Description: This callback is triggered when a text message is received. In the
AlipayRtcEngineIMListenercallback, if you do not use the text messaging feature, you do not need to set this callback.Parameters:
Parameter
Type
Description
msg4Receive
Msg4Receive
For more information, see Important parameters.
Return value: None.
onMsgSend
Declaration:
void onMsgSend( int error, String errorMessage, long msgId );Description: This callback returns the result of sending a text message. In the
AlipayRtcEngineIMListenercallback, if you do not use the text messaging feature, you do not need to set this callback.Parameters:
Parameter
Type
Description
error
int
A value of
0indicates success. Other values indicate failure.errorMessage
String
If error is not
0, this parameter provides a description of the failure.msgId
long
The corresponding message ID.
Return value: None.
onInviteResponse
Declaration:
void onInviteResponse( String inviteTaskId, int code, String msg );Description: This callback returns the result of sending an invitation. A code value of 0 indicates success. In
AlipayRtcEngineInviteListener, if you do not use the invitation feature, you do not need to set or listen for this callback.Parameters:
Parameter
Type
Description
inviteTaskId
String
The invitation task ID. This identifies the specific invitation call.
code
int
The invitation error code. The details are as follows:
0: The invitation was sent successfully.
1: A parameter is invalid.
2: The channel is invalid.
3: An invitation is already in progress.
4: The server failed to send the invitation.
5: The invitation timed out.
6: Reserved error code.
msg
String
The detailed information returned by the server.
Return value: None.
onReplyResponse
Declaration:
void onReplyResponse( String inviteTaskId, int code, String msg );Description: This callback returns the result of replying to an invitation. A code value of 0 indicates success. In
AlipayRtcEngineInviteListener, if you do not use the invitation feature, you do not need to set or listen for this callback.Parameters:
Parameter
Type
Description
inviteTaskId
String
The invitation task ID. This identifies the specific invitation call.
code
int
The invitation error code. The details are as follows:
0: The reply was sent successfully.
1: A parameter is invalid.
3: The previous call has not completed.
4: The server failed to process the request.
5: The call timed out.
6: Reserved error code.
msg
String
The detailed information returned by the server.
Return value: None.
onReplyOfInviteNotify
Declaration:
void onReplyOfInviteNotify(ReplyOfInviteInfo replyInfo );Description: After an invitation is sent, this callback returns the recipient's reply, such as accept or reject. In
AlipayRtcEngineInviteListener, if you do not use the invitation feature, you do not need to set or listen for this callback.Parameters:
Parameter
Type
Description
replyInfo
ReplyOfInviteInfo
For more information, see Important parameters.
Return value: None.
onCustomPublishPreviewInfo
Declaration:
void onCustomPublishPreviewInfo(PublishVideoSource videoSource, ARTVCView view );Description: This callback returns the local preview view for custom stream ingest. The video source is identified by videoSource. In
AlipayRtcEngineCustomPublishListener, if you do not use custom stream ingest or screen sharing, you do not need to set or listen for this callback.Parameters:
Parameter
Type
Description
videoSource
PublishVideoSource
For more information, see Important parameters.
view
ARTVCView
For more information, see Important parameters.
Return value: None.
onCustomPublishPreviewFirstFrame
Declaration:
void onCustomPublishPreviewFirstFrame( PublishVideoSource videoSource );Description: This event is triggered when the first frame of the local preview for custom stream ingest is displayed. The video source is identified by videoSource. In
AlipayRtcEngineCustomPublishListener, if you do not use custom stream ingest or screen sharing, you do not need to set or listen for this callback.Parameters:
Parameter
Type
Description
videoSource
PublishVideoSource
For more information, see Important parameters.
Return value: None.
onCustomPublishPreviewStop
Declaration:
void onCustomPublishPreviewStop( PublishVideoSource videoSource );Description: This event is triggered when the local preview for custom stream ingest stops. The video source is identified by videoSource. In
AlipayRtcEngineCustomPublishListener, if you do not use custom stream ingest or screen sharing, you do not need to set or listen for this callback.Parameters:
Parameter
Type
Description
videoSource
PublishVideoSource
For more information, see Important parameters.
Return value: None.