Event Listener
The Android SDK provides interfaces to listen to various events on the client app. Through these interfaces, TapTalk.io notifies the client app of events that happen on your app. You will need to register the listener objects to receive event callbacks from TapTalk.io.
Event Listener
Description
Listens to general event changes in the application
Listens to UI-related events in Room List View when UI implementation type is used
Listens to UI-related events in Chat Room View when UI implementation type is used
Listens to UI-related events in Chat Profile View when UI implementation type is used
Listens to UI-related events in My Account View when UI implementation type is used
Listens to custom keyboard-related events when UI implementation type is used
Listens to events when a new/updated message is received by the application
Listens to room status events such as typing events and online status

General events such as notifications will be notified through TapListener. A TapListener instance is required when initializing TapTalk.
We strongly suggest to override onTapTalkRefreshTokenExpired to handle authentication when the user's session has expired.
Java
Kotlin
TapListener tapListener = new TapListener() {
@Override
public void onInitializationCompleted(String instanceKey) {
// Initialization process has finished
}
@Override
public void onTapTalkRefreshTokenExpired() {
// Authentication is needed
}
@Override
public void onTapTalkUnreadChatRoomBadgeCountUpdated(int unreadCount) {
// Returns number of unread messages from the application
}
@Override
public void onNotificationReceived(TAPMessageModel message) {
// A new message from TapTalk.io is received
}
@Override
public void onUserLogout() {
// User has finished logging out from TapUI or TapTalk.logoutAndClearAllTapTalkData() process has completed
}
@Override
public void onTaskRootChatRoomClosed(Activity activity) {
// A chat room activity was closed by user when no other activity in the application is present
// You may start another activity to keep the app open, otherwise the app will stay closed
}
};
TapTalk.init(
CONTEXT,
APP_KEY_ID,
APP_KEY_SECRET,
APP_ICON,
APP_NAME,
APP_BASE_URL,
IMPLEMENTATION_TYPE,
tapListener);
var tapListener: TapListener = object : TapListener() {
override fun onInitializationCompleted(instanceKey: String) {
// Initialization process has finished
}
override fun onTapTalkRefreshTokenExpired() {
// Authentication is needed
}
override fun onTapTalkUnreadChatRoomBadgeCountUpdated(unreadCount: Int) {
// Returns number of unread messages from the application
}
override fun onNotificationReceived(message: TAPMessageModel?) {
// A new message from TapTalk.io is received
}
override fun onUserLogout() {
// User has finished logging out from TapUI or TapTalk.logoutAndClearAllTapTalkData() process has completed
}
override fun onTaskRootChatRoomClosed(activity: Activity?) {
// A chat room activity was closed by user when no other activity in the application is present
}
}
TapTalk.init(
CONTEXT,
APP_KEY_ID,
APP_KEY_SECRET,
APP_ICON,
APP_NAME,
APP_BASE_URL,
IMPLEMENTATION_TYPE,
tapListener)
TapListener listens to changes in the following methods:
Method Name
Invoked When
onInitializationCompleted()
TapTalk instance has finished initialization process.
onTapTalkRefreshTokenExpired()
User's refresh token has expired. An authentication with a new auth ticket is required.
onTapTalkUnreadChatRoomBadgeCountUpdated()
The number of unread messages in the application is updated. Returns the number of unread messages from the application.
onNotificationReceived()
User receives new message from TapTalk.io through notification. Returns the newly received message.
onUserLogout()
User has finished logging out from TapUI or TapTalk.logoutAndClearAllTapTalkData() process has completed
onTaskRootChatRoomClosed
A chat room activity was closed by user when no other activity in the application is present (application will close).

TapUIRoomListListener listens to UI-related events in Room List View when UI implementation type is used. You can register a TapUIRoomListListener instance in your application through the TapUI class as follows:
Java
Kotlin
TapUI.getInstance().addRoomListListener(new TapUIRoomListListener() {
@Override
public void onSearchChatBarTapped(Activity activity, TapUIMainRoomListFragment mainRoomListFragment) {
// Calling super will open search chat page by default
super.onSearchChatBarTapped(activity, mainRoomListFragment);
}
@Override
public void onCloseRoomListTapped(Activity activity) {
// Calling super will close TapTalk's room list activity by default
super.onCloseRoomListTapped(activity);
}
@Override
public void onTapTalkAccountButtonTapped(Activity activity) {
// Calling super will open TapTalk user account page by default
super.onTapTalkAccountButtonTapped(activity);
}
@Override
public void onNewChatButtonTapped(Activity activity) {
// Calling super will open TapTalk start new chat page by default
super.onNewChatButtonTapped(activity);
}
});
TapUI.getInstance().addRoomListListener(object : TapUIRoomListListener() {
override fun onSearchChatBarTapped(activity: Activity, mainRoomListFragment: TapUIMainRoomListFragment) {
// Calling super will open search chat page by default
super.onSearchChatBarTapped(activity, mainRoomListFragment)
}
override fun onCloseRoomListTapped(activity: Activity) {
// Calling super will close TapTalk's room list activity by default
super.onCloseRoomListTapped(activity)
}
override fun onTapTalkAccountButtonTapped(activity: Activity) {
// Calling super will open TapTalk user account page by default
super.onTapTalkAccountButtonTapped(activity)
}
override fun onNewChatButtonTapped(activity: Activity) {
// Calling super will open TapTalk start new chat page by default
super.onNewChatButtonTapped(activity)
}
})
Method Name
Invoked When
onSearchBarTapped()
Search bar in room list is tapped by active user. Returns the room list activity instance and TapUIMainRoomListFragment instance.
onCloseRoomListTapped()
TapTalk's room list activity is closed by active user. Returns the room list activity instance.
onTapTalkAccountButtonTapped()
My account button in top right room list view is tapped by active user. Returns the room list activity instance.
onNewChatButtonTapped()
Floating New Chat button on the bottom right of the room list view is tapped by active user. Returns the room list activity instance.

TapUIChatRoomListener listens to UI-related events in Chat Room View when UI implementation type is used. You can register a TapUIChatRoomListener instance in your application through the TapUI class as follows:
Java
Kotlin
TapUI.getInstance().addChatRoomListener(new TapUIChatRoomListener() {
@Override
public void onTapTalkChatRoomOpened(Activity activity, TAPRoomModel room, @Nullable TAPUserModel otherUser) {
// Returns activity instance and opened room model
}
@Override
public void onTapTalkChatRoomClosed(Activity activity, TAPRoomModel room, @Nullable TAPUserModel otherUser) {
// Returns activity instance and closed room model
}
@Override
public void onTapTalkActiveUserSendMessage(Activity activity, TAPMessageModel messageModel, TAPRoomModel room) {
// Returns activity instance, temporary message model to be sent, and the room where the message is being sent
}
@Override
public void onTapTalkUserProfileButtonTapped(Activity activity, TAPRoomModel room, TAPUserModel user) {
// Using super will open TapTalk user profile by default
super.onTapTalkUserProfileButtonTapped(activity, room, user);
}
@Override
public void onTapTalkGroupChatProfileButtonTapped(Activity activity, TAPRoomModel room) {
// Using super will open TapTalk group chat profile by default
super.onTapTalkGroupChatProfileButtonTapped(activity, room);
}
@Override
public void onTapTalkGroupMemberAvatarTapped(Activity activity, TAPRoomModel room, TAPUserModel user) {
// Using super will open TapTalk user profile by default
super.onTapTalkGroupMemberAvatarTapped(activity, room, user);
}
@Override
public void onTapTalkUserMentionTapped(Activity activity, TAPMessageModel messageModel, TAPUserModel user, boolean isRoomParticipant) {
// Using super will open TapTalk user profile by default
super.onTapTalkUserMentionTapped(activity, messageModel, user, isRoomParticipant);
}
@Override
public void onTapTalkMessageQuoteTapped(Activity activity, TAPMessageModel message, HashMap<String, Object> userInfo) {
// Returns activity instance, tapped message, and userInfo
}
});
TapUI.getInstance().addChatRoomListener(object : TapUIChatRoomListener() {
override fun onTapTalkChatRoomOpened(activity: Activity, room: TAPRoomModel, otherUser: TAPUserModel?) {
// Returns activity instance and opened room model
}
override fun onTapTalkChatRoomClosed(activity: Activity, room: TAPRoomModel, otherUser: TAPUserModel?) {
// Returns activity instance and closed room model
}
override fun onTapTalkActiveUserSendMessage(activity: Activity, messageModel: TAPMessageModel, room: TAPRoomModel) {
// Returns activity instance, temporary message model to be sent, and the destination room
}
override fun onTapTalkUserProfileButtonTapped(activity: Activity, room: TAPRoomModel, user: TAPUserModel?) {
// Using super will open TapTalk user profile by default
super.onTapTalkUserProfileButtonTapped(activity, room, user)
}
override fun onTapTalkGroupChatProfileButtonTapped(activity: Activity, room: TAPRoomModel) {
// Using super will open TapTalk group chat profile by default
super.onTapTalkGroupChatProfileButtonTapped(activity, room)
}
override fun onTapTalkGroupMemberAvatarTapped(activity: Activity, room: TAPRoomModel, user: TAPUserModel) {
// Using super will open TapTalk user profile by default
super.onTapTalkGroupMemberAvatarTapped(activity, room, user)
}
override fun onTapTalkUserMentionTapped(activity: Activity, messageModel: TAPMessageModel, user: TAPUserModel, isRoomParticipant: Boolean) {
// Using super will open TapTalk user profile by default
super.onTapTalkUserMentionTapped(activity, messageModel, user, isRoomParticipant)
}
override fun onTapTalkMessageQuoteTapped(activity: Activity, message: TAPMessageModel, userInfo: HashMap<String, Any>?) {
// Returns activity instance, tapped message, and userInfo
}
})
Method Name
Invoked When
onTapTalkChatRoomOpened()
A chat room is opened. Returns the opened activity instance and room model.
onTapTalkChatRoomClosed()
A chat room is closed. Returns the closed activity instance and room model.
onTapTalkActiveUserSendMessage()
Active user sends any message to a chat room. Message may not yet be delivered to the room when this happens. Returns the activity instance, message to be sent, and the destination room. Returned message is temporary and the values will be updated through socket once the message is delivered.
onTapTalkUserProfileButtonTapped()
Profile button in a personal chat room is tapped by active user. Returns the activity instance, room, and recipient user.
onTapTalkGroupChatProfileButtonTapped()
Profile button in a group chat room is tapped by active user. Returns the activity instance and room.
onTapTalkGroupMemberAvatarTapped()
A group member's profile picture on a message bubble in group chat room is tapped by active user. Returns the activity instance, room, and recipient user.
onTapTalkUserMentionTapped()
A user mention span in a chat bubble is tapped by active user. Returns activity instance, message model, mentioned user model, and isRoomParticipant
onTapTalkMessageQuoteTapped()
A quote inside a message bubble in a chat room is tapped by active user. Returns activity instance, tapped message, and userInfo. UserInfo is a HashMap object embedded inside a message containing data specified by client, and is generally null when not specified.

TapUIChatProfileListener listens to UI-related events in Chat Profile View when UI implementation type is used. You can register a TapUIChatProfileListener instance in your application through the TapUI class as follows:
Java
Kotlin
TapUI.getInstance().addChatProfileListener(new TapUIChatProfileListener() {
@Override
public void onReportUserButtonTapped(Activity activity, TAPRoomModel room, TAPUserModel reportedUser) {
// Returns activity instance, room model, and user model
}
@Override
public void onReportGroupButtonTapped(Activity activity, TAPRoomModel room) {
// Returns activity instance and room model
}
});
TapUI.getInstance().addChatProfileListener(object : TapUIChatProfileListener() {
override fun onReportUserButtonTapped(activity: Activity, room: TAPRoomModel, reportedUser: TAPUserModel) {
// Returns activity instance, room model, and user model
}
override fun onReportGroupButtonTapped(activity: Activity, room: TAPRoomModel) {
// Returns activity instance and room model
}
})
Method Name
Invoked When
onReportUserButtonTapped()
Active user taps the Report User button in chat profile view. Returns activity instance, room model, and the reported user model.
onReportGroupButtonTapped()
Active user taps the Report Group button in chat profile view. Returns activity instance and room model.

TapUIMyAccountListener listens to UI-related events in My Account View when UI implementation type is used. You can register a TapUIMyAccountListener instance in your application through the TapUI class as follows:
Java
Kotlin
TapUI.getInstance().addMyAccountListener(new TapUIMyAccountListener() {
@Override
public void onDeleteButtonInMyAccountPageTapped(@NonNull Activity activity) {
// Returns My Account activity instance
}
});
TapUI.getInstance().addMyAccountListener(object : TapUIMyAccountListener() {
override fun onDeleteButtonInMyAccountPageTapped(activity: Activity) {
// Returns My Account activity instance
}
})
Method Name
Invoked When
onDeleteButtonInMyAccountPageTapped()
Active user taps the Delete Account button in My Account view. Returns the currently active My Account activity instance.

TapCustomKeyboardListener bridges the custom keyboard-related events between TapTalk.io and the client app when UI implementation type is used. TapTalk.io will request custom keyboard items from the client app through this listener when a chat room is opened by the user. TapCustomKeyboardListener can be implemented using the TapUI class.
Java
Kotlin
TapUI.getInstance().addCustomKeyboardListener(new TapCustomKeyboardListener() {
@Override
public List<TAPCustomKeyboardItemModel> setCustomKeyboardItems(TAPRoomModel room, TAPUserModel activeUser, @Nullable TAPUserModel recipientUser) {
// Return items here if you wish to use custom keyboard in chat room
return null;
}
@Override
public void onCustomKeyboardItemTapped(Activity activity, TAPCustomKeyboardItemModel customKeyboardItem, TAPRoomModel room, TAPUserModel activeUser, @Nullable TAPUserModel recipientUser) {
// Do an action when user taps a custom keyboard item
}
});
TapUI.getInstance().addCustomKeyboardListener(object : TapCustomKeyboardListener() {
override fun setCustomKeyboardItems(
room: TAPRoomModel?,
activeUser: TAPUserModel?, @Nullable recipientUser: TAPUserModel?
): List<TAPCustomKeyboardItemModel>? {
// Return items here if you wish to use custom keyboard in chat room
return null
}
override fun onCustomKeyboardItemTapped(
activity: Activity?,
customKeyboardItem: TAPCustomKeyboardItemModel?,
room: TAPRoomModel?,
activeUser: TAPUserModel?, @Nullable recipientUser: TAPUserModel?
) {
// Do an action when user taps a custom keyboard item
}
})
To use custom keyboard in the chat room, return a list of TAPCustomKeyboardItemModel on the setCustomKeyboardItems() method in this listener. See the example below:JavaKotlin
Java
Kotlin
TapCustomKeyboardManager.getInstance().addCustomKeyboardListener(new TapCustomKeyboardListener() {
@Override
public List<TAPCustomKeyboardItemModel> setCustomKeyboardItems(TAPRoomModel room, TAPUserModel activeUser, @Nullable TAPUserModel recipientUser) {
List<TAPCustomKeyboardItemModel> customKeyboardItems = new ArrayList<>();
TAPCustomKeyboardItemModel customKeyboardItem1 = new TAPCustomKeyboardItemModel(
"customKeyboardItem1",
getDrawable(R.drawable.keyboard_icon_1),
"Hello, " + room.getRoomName()
);
TAPCustomKeyboardItemModel customKeyboardItem2 = new TAPCustomKeyboardItemModel(
"customKeyboardItem2",
"https://www.yoururl.com/image2.png",
"Hello, my name is " + activeUser.getName()
);
customKeyboardItems.add(customKeyboardItem1);
customKeyboardItems.add(customKeyboardItem2);
return customKeyboardItems;
}
@Override
public void onCustomKeyboardItemTapped(Activity activity, TAPCustomKeyboardItemModel customKeyboardItem, TAPRoomModel room, TAPUserModel activeUser, @Nullable TAPUserModel recipientUser) {
if (customKeyboardItem.getItemID().equals("customKeyboardItem1")) {
// Custom keyboard item 1 was tapped by user
} else if (customKeyboardItem.getItemID().equals("customKeyboardItem2")) {
// Custom keyboard item 2 was tapped by user
}
}
});
TapCustomKeyboardManager.getInstance().addCustomKeyboardListener(object : TapCustomKeyboardListener() {
override fun setCustomKeyboardItems(
room: TAPRoomModel?,
activeUser: TAPUserModel?, @Nullable recipientUser: TAPUserModel?
): List<TAPCustomKeyboardItemModel> {
val customKeyboardItems = ArrayList()
val customKeyboardItem1 = TAPCustomKeyboardItemModel(
"customKeyboardItem1",
getDrawable(R.drawable.keyboard_icon_1),
"Hello, " + room.getRoomName()
)
val customKeyboardItem2 = TAPCustomKeyboardItemModel(
"customKeyboardItem2",
"https://www.yoururl.com/image2.png",
"Hello, my name is " + activeUser!!.name
)
customKeyboardItems.add(customKeyboardItem1)
customKeyboardItems.add(customKeyboardItem2)
return customKeyboardItems
}
override fun onCustomKeyboardItemTapped(
activity: Activity?,
customKeyboardItem: TAPCustomKeyboardItemModel?,
room: TAPRoomModel?,
activeUser: TAPUserModel?, @Nullable recipientUser: TAPUserModel?
) {
if (customKeyboardItem!!.itemID == "customKeyboardItem1") {
// Custom keyboard item 1 was tapped by user
} else if (customKeyboardItem.itemID == "customKeyboardItem2") {
// Custom keyboard item 2 was tapped by user
}
}
})
Method Name
Invoked When
setCustomKeyboardItems()
Chat room is opened. TapTalk.io will request custom keyboard items from the client app to be displayed in the chat room. Returns room, active user, and the recipient user (only for personal chat room)
onCustomKeyboardItemTapped()
A custom keyboard item in a chat room is tapped by the user. Returns the activity instance, custom keyboard item, room, active user, and recipient user (only for personal chat room)

TapCoreMessageListener listens to message-related events, such as receiving new or updated message. TapCoreMessageListener can be registered through the TapCoreMessageManager class.JavaKotlin
Java
Kotlin
TapCoreMessageManager.getInstance().addMessageListener(new TapCoreMessageListener() {
@Override
public void onReceiveNewMessage(TAPMessageModel message) {
}
@Override
public void onReceiveUpdatedMessage(TAPMessageModel message) {
}
@Override
public void onMessageDeleted(TAPMessageModel message) {
}
@Override
public void onRequestMessageFileUpload(TAPMessageModel message, Uri fileUri) {
}
});
TapCoreMessageManager.getInstance().addMessageListener(object : TapCoreReceiveMessageListener() {
override fun onReceiveNewMessage(message: TAPMessageModel?) {
}
override fun onReceiveUpdatedMessage(message: TAPMessageModel?) {
}
override fun onMessageDeleted(message: TAPMessageModel?) {
}
override fun onRequestMessageFileUpload(message: TAPMessageModel?, fileUri: Uri?) {
}
})
Method Name
Invoked When
onReceiveNewMessage()
A new message is received. Returns the newly received message.
onReceiveUpdatedMessage()
An updated message is received. Returns the updated message.
onMessageDeleted()
A message is deleted. Returns the deleted message.
onRequestMessageFileUpload()
Active user sends a message with file, such as image, video, or document. Returns the message to be sent and the uri of the file to be uploaded by the client.
Note: the callback onRequestMessageFileUpload() will only be invoked when the user calls setUploadMessageFileToExternalServerEnabled(true) in TapCoreMessageManager. Enabling this will prevent the SDK from uploading message files, which are image, video, or document, to TapTalk servers, means the message will not be sent until the client returns the uploaded file's URL to the SDK through the onFileUploadCompleted method in TapCoreMessageManager.

Room status events such as typing events and online status are notified through TapCoreChatRoomListener. An instance of TapCoreChatRoomListener can be registered from the TapCoreChatRoomManager class.
Java
Kotlin
TapCoreChatRoomManager.getInstance().addChatRoomListener(new TapCoreChatRoomListener() {
@Override
public void onReceiveStartTyping(String roomID, TAPUserModel user) {
}
@Override
public void onReceiveStopTyping(String roomID, TAPUserModel user) {
}
@Override
public void onReceiveOnlineStatus(TAPUserModel user, Boolean isOnline, Long lastActive) {
}
});
TapCoreChatRoomManager.getInstance().addChatRoomListener(object : TapCoreChatRoomListener() {
override fun onReceiveStartTyping(roomID: String?, user: TAPUserModel?) {
}
override fun onReceiveStopTyping(roomID: String?, user: TAPUserModel?) {
}
override fun onReceiveOnlineStatus(
user: TAPUserModel?,
isOnline: Boolean?,
lastActive: Long?
) {
}
})
Method Name
Invoked When
onReceiveStartTyping()
Another user starts typing a message in a chat room. Returns the room ID and typing user.
onReceiveStopTyping()
Another user stops typing a message in a chat room. Returns the room ID and typing user.
onReceiveOnlineStatus()
Another user comes online or offline. Returns the updated user, online status, and the updated user's last active time stamp.
Copy link
On this page
TapListener
TapUIRoomListListener
TapUIChatRoomListener
TapUIChatProfileListener
TapUIMyAccountListener
TapCustomKeyboardListener
TapCoreMessageListener
TapCoreChatRoomListener