Attachment Gallery Activity

LAST EDIT Apr 26 2021

AttachmentGalleryActivity is an Activity used to display attachments that the users have sent in the chat. It is an image gallery where users can see the pictures, share, download, and use a menu to navigate through the pictures.

AttachmentGalleryActivity showing a screen shot.

Handling user input


There are 4 behaviours that can be customized by the following handlers:

  • AttachmentGalleryActivity.AttachmentReplyOptionHandler

  • AttachmentGalleryActivity.AttachmentShowInChatOptionHandler

  • AttachmentGalleryActivity.AttachmentDownloadOptionHandler

  • AttachmentGalleryActivity.AttachmentDeleteOptionHandler

The next section shows how to implement the listeners and inject the desired behaviour.

Navigating to Attachment Gallery


There are two ways to navigate to this screen.

  1. It will be opened from Message List View when a user clicks on an attachment (an image, for example).

  2. It can be called from the client-side using AttachmentGalleryDestination.


The MessageListView already calls the AttachmentGalleryActivity and the click handlers can be set using MessageListView, using setAttachmentReplyOptionClickHandler, setAttachmentShowInChatOptionClickHandler, setDownloadOptionHandler and setAttachmentDeleteOptionClickHandler.

There is no need for specific code to navigate to AttachmentGalleryActivity, just set the handlers mentioned above to change the default behaviour. The next section shows how to navigate to Attachment Gallery from anywhere.


To use AttachmentGalleryDestination, you need to to implement the click handlers of the buttons in its overflow menu (the three dots).

  • AttachmentReplyOptionHandler

  • AttachmentShowInChatOptionHandler

  • AttachmentDownloadOptionHandler

  • AttachmentDeleteOptionHandler

Here's how you set those when creating the destination:

Then, you need to register the destination with the ActivityResultRegistry and set the data to display:

As the last step, fire the navigation request: