Abstract visualisation of custom post ranking in a feed

How to build a chronological or custom activity feed in your Android app

Italo Orihuela
Italo Orihuela
Oct 28, 2023

For social media and community platforms, the global feed is a crucial component. It’s the hub where users can discover and engage with the latest content. Today, we’ll be exploring two distinct methods of implementing a global feed using the Amity Social Cloud SDK: the `getGlobalFeed` and `getCustomPostRanking` methods. These methods allow you to customize your content experience to better align with your users’ interests and preferences.

Whether you’re looking to display posts in chronological order or use a score-sorting mechanism to highlight the most engaging content, this tutorial will guide you through the process. So, let’s dive in and explore how to create a more dynamic and engaging community experience for your users.


Installing the Amity Android SDK

Before we start, it’s important to ensure that the Amity Android SDK is installed and set up in your Android project. Here are the requirements and steps to install the SDK:


  • Android 5.0 (API level 21) and above
  • Target sdk version 29 and above
  • Compile SDK Version 29 and above
  • JVM target should be 1.8


Add the Jitpack repository in your project level `build.gradle` at the end of repositories:

If you’re using Gradle 6.8 or above:

If you’re using Gradle 6.7 or below:

Add the dependency in your module level `build.gradle`. Find the latest SDK version at Changelog.

If you’re using Gradle groovy:

If you’re using Kotlin Gradle DSL:

Initializing the SDK

After installing the SDK, you need to initialize it in your application class. Here’s how you can do it:

In the above code, `ChatApp` is your application class. The `AmityCoreClient.setup( )` method initializes the Amity SDK with the application context.

The following code, authenticates the session:

Step 1: Import the necessary classes

Make sure to import the necessary classes. This includes the `AmityFeedRepository`, `AmityPost`, and `AmityPagingData` classes.

Step 2: Query the Global Feed in Chronological Order

The `getGlobalFeed` method allows you to retrieve posts in chronological order. Here’s how you can implement it:

Step 3: Query the Global Feed with Custom Post Ranking

If you want to present posts based on their relevance, you can use the `getCustomRankingGlobalFeed` method. This method uses a score-sorting mechanism to ensure the most engaging content is at the top of the feed.

In both methods, replace `//results` with your own code to handle the results. The `subscribe()` method is used to start the query. The `doOnNext` method is called each time a new page of results is loaded. The `PagingData<AmityPost>` object contains the posts in the current page.

Final Thoughts

Implementing a global feed that aligns with your users’ interests and preferences can significantly enhance the user experience on your platform. With the `getGlobalFeed` and `getCustomPostRanking` methods provided by the Amity Social Cloud SDK, you can easily customize your global feed to display posts in chronological order or based on their relevance. We hope this tutorial has been helpful in guiding you through the process.