SDKsAndroid
Update typing status
Report the current conversation typing state with the Android SDK.
Report the user's typing status within a conversation. When the user starts editing text in the input box, call this method with focus set to true to signal "typing". When the user sends the message, clears the input box, blurs the input focus, or navigates away from the chat screen, call this method with focus set to false to clear the typing status immediately. Debouncing input changes is strongly recommended to avoid sending duplicate events too frequently.
Code example
String conversationID = "si_user_a_user_b";
// Report when user starts typing
OpenIMClient.getInstance().conversationManager.changeInputState(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Typing state reported successfully
}
@Override
public void onError(int code, String error) {
// Failed to report typing state
}
},
conversationID,
true
);
// Clear typing state when user stops typing or navigates away
OpenIMClient.getInstance().conversationManager.changeInputState(
null,
conversationID,
false
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. Pass null if no callback confirmation is needed. |
conversationID | String | Yes | Globally unique ID of the target conversation. |
focus | boolean | Yes | Whether the user is actively typing: true to report typing, false to clear typing. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback confirms that the typing status was transmitted to the server. Passnullas the callback if confirmation is not required. - Asynchronous event delivery: Peers in the conversation receive typing notifications through
OnConversationListener.onConversationUserInputStatusChanged. The Android SDK delivers the event data as a JSON payload:
@Override
public void onConversationUserInputStatusChanged(String payload) {
InputStatesChangedData state = JsonUtil.toObj(
payload,
InputStatesChangedData.class
);
if (state == null || state.getConversationID() == null) {
return;
}
// state.getConversationID() identifies the target conversation
// state.getUserID() identifies the typing user
// state.getPlatformIDs() contains platform IDs where the user is typing
}Merge and display typing indicators using state.getConversationID() and state.getUserID().
- Re-query calibration: Typing indicators are ephemeral and expire automatically after a timeout. To actively query whether a user is currently typing, see Retrieve typing status.
Was this page helpful?