SDKsAndroid
Track message sending progress
Use the progress callback on OnMsgSendCallback to update media sending progress.
Monitor underlying file upload progress in real time when sending media messages such as images, audio, video, or files using the onProgress callback of OnMsgSendCallback. This is ideal for updating upload progress bars or percentage indicators on the chat UI.
Code example
OpenIMClient.getInstance().messageManager.sendMessage(
new OnMsgSendCallback() {
@Override
public void onProgress(long progress) {
// progress is the upload percentage (0 to 100)
// Update UI progress indicators or percentage text
}
@Override
public void onSuccess(Message sentMessage) {
// Sent successfully, update local message status
}
@Override
public void onError(int code, String error) {
// Handle send error
}
},
message,
peerUserID,
null,
offlinePushInfo
);Callback parameters
progress(long): Current upload completion percentage, ranging from0to100.
Return value
onProgress fires during the upload phase of local media files. Plain text messages, custom messages, and pre-uploaded URL messages do not trigger upload progress callbacks.
State changes after the call
- Upload lifecycle: The SDK streams upload progress via
onProgress. Once uploading completes, the SDK submits the message payload to the server. - Terminal callback: The request concludes when either
onSuccessoronErroris invoked.
Was this page helpful?