Skip to main content

Starting March 27, 2026, RC is rebranded as Nexconn. Existing RC SDK customers can continue using this documentation. New customers should refer to the Nexconn developer documentation.

Message Toast Interception

IMKit utilizes Android's Toast mechanism to provide operation result prompts or application status change notifications. Starting from version 5.6.3, it supports global message style configuration through interceptors.

Intercepting Toast Messages

tip

Requires IMKit version ≥ 5.6.3.

The willToast method of ToastInterceptor is called on the UI thread. Returning false in the willToast method indicates the application needs to intercept the Toast.

import io.rong.imkit.utils.ToastUtils;


ToastUtils.setInterceptor(
new ToastUtils.ToastInterceptor() {
@Override
public boolean willToast(
@NonNull Context context, @NonNull CharSequence text, int duration) {
String s = "Intercepted toast: " + text;
Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
return false;
}
});

To disable the interceptor, simply set it to null.