> For the complete documentation index, see [llms.txt](https://docs.taptalk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.taptalk.io/~/changes/FMvVnz8ZkLFBmR0Wx2wq/onetalk-omnichannel-documentation/onetalk-channel-integration/live-chat/onetalk-android/event-listener.md).

# Event Listener

The Android SDK provides event listener to listen to various events on the client app. Through these event delegates, TapTalk.io notifies the client app of events that happen on your app.

You can listen through general events from the Live Chat SDK through the **TapTalkLiveListener** class. An instance of TapTalkLiveListener will be required to initialize the Live Chat SDK. A more complete implementation will be explained in this page.

{% tabs %}
{% tab title="Java" %}
{% code title="Application.java" %}

```java
TapTalkLive.init(
    CONTEXT, 
    APP_KEY_SECRET, 
    CLIENT_APP_ICON, 
    CLIENT_APP_NAME,
    new TapTalkLiveListener() {
        @Override
        public void onInitializationCompleted() {
            // Initialization success
        }
        
        @Override
        public void onInitializationFailed(TTLErrorModel error) {
            // Initialization failed
        }

        @Override
        public void onNotificationReceived(TAPMessageModel message) {
            // TapTalk.io SDK receives a message notification
            // Calling super will show TapTalk.io's default notification for the app
            super.onNotificationReceived(message);
        }
    
        @Override
        public void onCloseButtonInHomePageTapped(Activity activity) {
            // User closes the home page
        }
    
        @Override
        public void onCloseButtonInCreateCaseFormTapped(Activity activity) {
            // User closes the create case form
        }
    
        @Override
        public void onCloseButtonInCaseListTapped(Activity activity) {
            // User closes the case list page
        }
    
        @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
    }
    
        @Override
        public void onSeeAllMessagesButtonTapped(Activity activity) {
            // User taps the See All Messages button in home page
            // Calling super will open the case list page
            super.onSeeAllMessagesButtonTapped(activity);
        }
    
        @Override
        public void onCreateNewMessageButtonTapped(Activity activity) {
            // User taps the New Messages button in home or case list page
            // Calling super will open the create new case form
            super.onCreateNewMessageButtonTapped(activity);
        }
    
        @Override
        public void onCaseListItemTapped(Activity activity, TAPMessageModel lastMessage) {
            // User taps a case from a list in home or case list page
            // Calling super will open the selected chat room
            super.onCaseListItemTapped(activity, lastMessage);
        }
    
        @Override
        public void onFaqChildTapped(Activity activity, TTLScfPathModel scfPath) {
            // User taps a FAQ from a list in home or FAQ details page
            // Calling super will open the selected FAQ details page
            super.onFaqChildTapped(activity, scfPath);
        }
    
        @Override
        public void onCloseButtonInFaqDetailsTapped(Activity activity, TTLScfPathModel scfPath) {
            // User closes the FAQ details page
        }
    
        @Override
        public void onTalkToAgentButtonTapped(Activity activity, TTLScfPathModel scfPath) {
            // User taps the Talk to Agent button in home or FAQ details page
            // Calling super will open the create new case form
            super.onTalkToAgentButtonTapped(activity, scfPath);
        }
    }
);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code title="Application.kt" %}

```kotlin
TapTalkLive.init(
    CONTEXT, 
    APP_KEY_SECRET, 
    CLIENT_APP_ICON, 
    CLIENT_APP_NAME,
    object : TapTalkLiveListener() {
        override fun onInitializationCompleted() {
            // Initialization success
        }
        
        override fun onInitializationFailed(error: TTLErrorModel?) {
            // Initialization failed
        }

        override fun onNotificationReceived(message: TAPMessageModel?) {
            // TapTalk.io SDK receives a message notification
            // Calling super will show TapTalk.io's default notification for the app
            super.onNotificationReceived(message)
        }
        
        override fun onCloseButtonInHomePageTapped(activity: Activity?) {
            // User closes the home page
        }
    
        override fun onCloseButtonInCreateCaseFormTapped(activity: Activity?) {
            // User closes the create case form
        }
    
        override fun onCloseButtonInCaseListTapped(activity: Activity?) {
            // User closes the case list page
        }
    
        override fun 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
        }
    
        override fun onSeeAllMessagesButtonTapped(activity: Activity?) {
            // User taps the See All Messages button in home page
            // Calling super will open the Case List page
            super.onSeeAllMessagesButtonTapped(activity)
        }
    
        override fun onCreateNewMessageButtonTapped(activity: Activity?) {
            // User taps the New Messages button in home or case list page
            // Calling super will open the Create New Case form
            super.onCreateNewMessageButtonTapped(activity)
        }
    
        override fun onCaseListItemTapped(activity: Activity?, lastMessage: TAPMessageModel?) {
            // User taps a case from a list in home or case list page
            // Calling super will open the selected chat room
            super.onCaseListItemTapped(activity, lastMessage)
        }
    
        override fun onFaqChildTapped(activity: Activity?, scfPath: TTLScfPathModel?) {
            // User taps a FAQ from a list in home or FAQ details page
            // Calling super will open the selected FAQ details page
            super.onFaqChildTapped(activity, scfPath)
        }
    
        override fun onCloseButtonInFaqDetailsTapped(activity: Activity?, scfPath: TTLScfPathModel?) {
            // User closes the FAQ details page    
        }
    
        override fun onTalkToAgentButtonTapped(activity: Activity?, scfPath: TTLScfPathModel?) {
            // User taps the Talk to Agent button in home or FAQ details page
            // Calling super will open the Create New Case form
            super.onTalkToAgentButtonTapped(activity, scfPath)
        }
    }
)
```

{% endcode %}
{% endtab %}
{% endtabs %}

TapTalkLiveListener listens to changes in the following methods:

<table data-header-hidden data-full-width="false"><thead><tr><th width="412">Method Name</th><th>Invoked When</th></tr></thead><tbody><tr><td>Method Name</td><td>Invoked When</td></tr><tr><td><strong><code>onInitializationCompleted()</code></strong></td><td>TapTalkLive instance has finished initialization process.</td></tr><tr><td><strong><code>onInitializationFailed()</code></strong></td><td>TapTalkLive instance initialization failed with an error.</td></tr><tr><td><strong><code>onNotificationReceived()</code></strong></td><td>User receives new message from TapTalk.io through notification. Returns the newly received <strong>message</strong>.</td></tr><tr><td><strong><code>onCloseButtonInHomePageTapped()</code></strong></td><td>User closes the home page. Returns the home <strong>activity</strong> instance.</td></tr><tr><td><strong><code>onCloseButtonInCreateCaseFormTapped()</code></strong></td><td>User closes the create case form page. Returns the create case form <strong>activity</strong> instance.</td></tr><tr><td><strong><code>onCloseButtonInCaseListTapped()</code></strong></td><td>User closes the case list page. Returns the case list <strong>activity</strong> instance.</td></tr><tr><td><strong><code>onTaskRootChatRoomClosed()</code></strong></td><td>A chat room activity was closed by user when no other activity in the application is present (application will close).</td></tr><tr><td><strong><code>onSeeAllMessagesButtonTapped()</code></strong></td><td>User taps the See All Messages button in home page. Returns the current <strong>activity</strong> instance.</td></tr><tr><td><strong><code>onCreateNewMessageButtonTapped()</code></strong></td><td>User taps the New Messages button in home or case list page. Returns the current <strong>activity</strong> instance.</td></tr><tr><td><strong><code>onCaseListItemTapped()</code></strong></td><td>User taps a case from a list in home or case list page. Returns the current <strong>activity</strong> instance and selected case's <strong>last message</strong>.</td></tr><tr><td><strong><code>onFaqChildTapped()</code></strong></td><td>User taps a FAQ from a list in home or FAQ details page. Returns the current <strong>activity</strong> instance and selected <strong>SCF Path</strong>.</td></tr><tr><td><strong><code>onCloseButtonInFaqDetailsTapped()</code></strong></td><td>User closes the FAQ details page. Returns the current <strong>activity</strong> instance and selected <strong>SCF Path</strong>.</td></tr><tr><td><strong><code>onTalkToAgentButtonTapped()</code></strong></td><td>User taps the Talk to Agent button in home or FAQ details page. Returns the current <strong>activity</strong> instance and selected <strong>SCF Path</strong>.</td></tr></tbody></table>
