Typing Status
The typing status feature provides real-time visual feedback when other users are composing messages. When a user starts typing, the title bar displays "Typing..." until the message is sent or fully deleted. If typing inactivity exceeds 6 seconds, the indicator disappears automatically. The SDK sends typing status messages (containing TypingStatusMessage
objects with type identifier RC:TypSts
) to peer users whenever input field content changes.
IMKit's default conversation Activity (RongConversationActivity
) includes built-in typing status display in the title bar. For Fragment-based chat UIs, implement your own typing status indicator.
Limitations
- Available only in one-to-one chat
- May generate excessive status messages due to undetermined user input actions. By default, multiple typing events within 6 seconds trigger only one status message
- Consider disabling this feature if excessive status messages become problematic
Implementation
No additional setup is required when using IMKit's default RongConversationActivity
.
Monitoring typing status in custom chat UIs
IMKit's ConversationFragment
doesn't include title bar implementation. For custom Fragment-based chat UIs, implement typing status display manually. The SDK automatically sends typing status messages when input changes occur. Receiving clients should display indicators like "Typing..." based on these messages.
Applications only need to register listeners in custom chat Activities to update title bars upon receiving callbacks.
-
Register a typing status listener in your custom chat Activity's
onCreate()
:RongIMClient.setTypingStatusListener(new RongIMClient.TypingStatusListener() {
@Override
public void onTypingStatusChanged(Conversation.ConversationType type, String targetId, Collection<TypingStatus> typingStatusSet) {
// Only display when the typing session matches current conversation
if (type.equals(mConversationType) && targetId.equals(mTargetId)) {
// Count represents number of currently typing users (always 1 in 1:1 chat)
int count = typingStatusSet.size();
if (count > 0) {
Iterator iterator = typingStatusSet.iterator();
TypingStatus status = (TypingStatus) iterator.next();
String objectName = status.getTypingContentType();
MessageTag textTag = TextMessage.class.getAnnotation(MessageTag.class);
MessageTag voiceTag = VoiceMessage.class.getAnnotation(MessageTag.class);
// Determine whether peer is typing text or voice message
if (objectName.equals(textTag.value())) {
// Display "Typing..."
} else if (objectName.equals(voiceTag.value())) {
// Display "Recording..."
}
} else {
// No active typing, restore original title
}
}
}
}); -
The
onTypingStatusChanged()
callback triggers when typing starts/stops. An empty typingStatusSet indicates typing cessation—hide the indicator and restore the original title.
Customization
Adjust default typing status message interval
Override the default 6000ms interval by creating/modifying rc_configuration.xml
in your app's res/values
directory:
<integer name="rc_disappear_interval">6000</integer>
Disabling Typing Status
IMKit enables typing status by default. Disable it via XML configuration:
<bool name="rc_typing_status">false</bool>