Skip to main content
This page covers Android-specific lifecycle patterns for LoginListener. For the basic add/remove API, see Authentication.

Android Activity/Fragment Example

Register the listener in onCreate() and remove it in onDestroy() to follow the Android lifecycle. Callbacks provide User objects on success and CometChatException on failure:
Always remove login listeners when they’re no longer needed (e.g., in onDestroy() or when navigating away). Failing to remove listeners can cause memory leaks and duplicate event handling.

Next Steps

Authentication

Login methods, Auth Key vs Auth Token, and logout

Real-Time Listeners

Register listeners for messages, users, groups, and calls

Connection Status

Monitor connection status to CometChat servers

Setup SDK

Initialize the SDK before logging in users