The FastComments Android SDK provides a simple way to add real-time commenting functionality to your Android applications.
Give your coding agent the FastComments context it needs - widgets, configuration, Secure SSO, the REST API, and the SDKs:
npx skills add fastcomments/skillsWorks with Claude Code, Codex, Cursor, Copilot, Gemini, and every other agent the skills CLI supports.
- 🔄 Live commenting with real-time updates
- 📱 Native Android UI components
- 🧵 Threaded discussions with replies
- 👤 Secure SSO authentication
- 👍 Voting system with customizable styles
- 📊 Polls in comments with live results
- 🔔 User notifications and presence
- 🔍 Comment moderation capabilities
- 📱 Social feed integration
- ♾️ Infinite scroll pagination
- 🎨 Comprehensive theming
- Android SDK 26+ (Android 8.0 Oreo or later)
- Java 8+
Add the FastComments SDK to your app's build.gradle.kts file:
dependencies {
implementation("com.fastcomments:android-sdk:2.1.0")
}Make sure you have the Repsy repository in your project's settings.gradle.kts:
dependencyResolutionManagement {
repositories {
maven {
url = uri("https://repo.repsy.io/mvn/winrid/fastcomments")
}
// other repositories...
}
}<com.fastcomments.sdk.FastCommentsView
android:id="@+id/commentsView"
android:layout_width="match_parent"
android:layout_height="match_parent" />// Configure the SDK
val config = CommentWidgetConfig(
"your-tenant-id",
"page-url-id",
"Page Title",
"yourdomain.com",
"Site Name"
)
// Additional configuration options
config.voteStyle = VoteStyle.UpDown // or VoteStyle.Heart
config.enableInfiniteScrolling = true
config.hasDarkBackground = true // for dark mode support
// Initialize the SDK
val sdk = FastCommentsSDK(config)
// Find the comments view in your layout
val commentsView = findViewById<FastCommentsView>(R.id.commentsView)
// Set the SDK instance for the view
commentsView.setSDK(sdk)
// Load comments
commentsView.load()Implement secure authentication for your users:
// Create user data (ideally on your server)
val userData = SecureSSOUserData(
"user-id",
"[email protected]",
"User Name",
"https://path-to-avatar.jpg"
)
// Generate SSO token (should be done server-side!)
val sso = FastCommentsSSO.createSecure("YOUR_API_KEY", userData)
val token = sso.prepareToSend()
// Add to config
config.sso = tokenDisplay a social media style feed with comments:
// Configure the SDK
CommentWidgetConfig config = new CommentWidgetConfig();
config.tenantId = "your-tenant-id";
config.urlId = "page-url-id";
// Initialize the Feed SDK
FastCommentsFeedSDK feedSDK = new FastCommentsFeedSDK(config);
// Set up the feed view
FastCommentsFeedView feedView = findViewById(R.id.feedView);
feedView.setSDK(feedSDK);
// Set interaction listener
feedView.setFeedViewInteractionListener(new FastCommentsFeedView.OnFeedViewInteractionListener() {
@Override
public void onFeedLoaded(List<FeedPost> posts) {
// Feed loaded successfully
}
@Override
public void onFeedError(String errorMessage) {
// Handle errors
}
@Override
public void onPostSelected(FeedPost post) {
// User selected a post
}
@Override
public void onCommentsRequested(FeedPost post) {
// Show comments for the post
CommentsDialog dialog = new CommentsDialog(context, post, feedSDK);
dialog.show();
}
});
// Load the feed
feedView.load();Add a real-time chat interface to your app:
// Add LiveChatView to your layout XML
// <com.fastcomments.sdk.LiveChatView
// android:id="@+id/liveChatView"
// android:layout_width="match_parent"
// android:layout_height="match_parent" />
// Create a configuration for the SDK
val config = CommentWidgetConfig().apply {
tenantId = "your-tenant-id"
urlId = "chat-room-identifier"
pageTitle = "Chat Room Name"
}
LiveChatView.setupLiveChatConfig(config)
// Optional: Add user authentication
val userData = SimpleSSOUserData(
"User Name",
"[email protected]",
"https://path-to-avatar.jpg"
)
val sso = FastCommentsSSO(userData)
config.sso = sso.prepareToSend()
// Initialize the SDK
val sdk = FastCommentsSDK().configure(config)
// Set up the live chat view
val liveChatView = findViewById<LiveChatView>(R.id.liveChatView)
liveChatView.setSDK(sdk)
liveChatView.load()
// Don't forget lifecycle handling
override fun onResume() {
super.onResume()
sdk.refreshLiveEvents()
}
override fun onDestroy() {
super.onDestroy()
sdk.cleanup()
}Check out these demo implementations:
- Basic Comments Example
- Secure SSO Implementation
- Feed Integration Example
- Live Chat Example
- Comments Dialog Example
The SDK provides many configuration options through the CommentWidgetConfig class:
| Option | Description |
|---|---|
tenantId |
Your FastComments account ID |
urlId |
ID representing the current page |
sso |
SSO token for authentication |
allowAnon |
Allow anonymous commenting |
voteStyle |
UpDown or Heart voting style |
hideAvatars |
Hide user avatars |
hasDarkBackground |
Indicates dark mode |
customCSS |
Custom CSS styles |
enableInfiniteScrolling |
Enable infinite scroll pagination |
readonly |
Disable commenting but show comments |
disableVoting |
Disable voting functionality |
disableLiveCommenting |
Disable real-time updates |
pollCreation |
Who can attach a poll to a comment: NUMBER_0 disabled, NUMBER_1 admins and moderators, NUMBER_2 everyone |
pollVoting |
Who can vote on polls: NUMBER_0 logged in users, NUMBER_1 anyone |
Polls work the same as in the web widget, and turn on from the same widget settings in your FastComments dashboard (or with pollCreation / pollVoting above).
- Comments with a poll show it under their text. Readers vote by tapping an option, can show or hide results before voting, and can change their vote. Tallies update live as others vote.
- Polls can close on a date, hide results until you vote, and make voters visible to admins or to everyone ("See who voted").
- When the viewer may create polls,
FastCommentsView's comment input shows a poll button that opens the poll builder. The toolbar row appears for it even if you never turned the toolbar on;sdk.setCommentToolbarEnabled(false)hides it, poll button included, andsetPollCreationEnabled(false)on the input removes only the poll button. CallsetCommentToolbarEnabledbefore creating theFastCommentsView, since the input reads it when it receives the SDK; for a view already on screen, callgetBottomCommentInput().setToolbarVisible(false)instead. The live chat input leaves it out, like the web live chat.
To post a poll from your own UI, pass a CommentPollInput to postComment:
CommentPollInput poll = new CommentPollInput()
.question("Where should we eat?")
.options(Arrays.asList("Tacos", "Ramen"))
// Optional: an ISO 8601 close date, PollPrivacy value, and results hidden until you vote.
.closesAt(Instant.now().plus(1, ChronoUnit.DAYS).toString())
.privacy(PollPrivacy.NUMBER_2.getValue())
.requireVoteToSeeResults(true);
sdk.postComment("Lunch vote", null, null, poll, callback);sdk.votePoll(commentId, optionId, callback) and sdk.getPollVoters(commentId, page, search, callback) cover voting and the voter list. Poll colors are listed in THEMING.md.
All buttons and UI elements in the FastComments SDK are themeable. Use the FastCommentsTheme.Builder for complete control over your app's branding.
val theme = FastCommentsTheme.Builder()
// Action buttons: Send, vote, menu, like/share buttons
.setActionButtonColor(Color.parseColor("#FF1976D2"))
// Reply buttons: Comment reply buttons
.setReplyButtonColor(Color.parseColor("#FF4CAF50"))
// Toggle buttons: Show/hide replies buttons
.setToggleRepliesButtonColor(Color.parseColor("#FFFF5722"))
// Load more buttons: Pagination buttons
.setLoadMoreButtonTextColor(Color.parseColor("#FF9C27B0"))
.setPrimaryColor(Color.parseColor("#FF6200EE"))
.setLinkColor(Color.parseColor("#FF1976D2"))
.setDialogHeaderBackgroundColor(Color.parseColor("#FF333333"))
.build()
// Apply the theme
sdk.setTheme(theme)Override color resources in your colors.xml for simple branding:
<!-- In your app's res/values/colors.xml -->
<resources>
<!-- Change all primary UI elements -->
<color name="primary">#FF1976D2</color>
<!-- Or customize specific button types -->
<color name="fastcomments_action_button_color">#FF1976D2</color>
<color name="fastcomments_reply_button_color">#FF4CAF50</color>
<color name="fastcomments_toggle_replies_button_color">#FFFF5722</color>
<color name="fastcomments_load_more_button_text_color">#FF9C27B0</color>
</resources>Every button in the SDK supports theming:
- Send buttons, vote buttons, menu buttons, reply buttons
- Show/hide replies buttons, load more buttons
- Feed action buttons (like, comment, share)
- Dialog buttons (submit, cancel, save)
- Dynamic task buttons in feed posts
For detailed theming documentation, see THEMING.md.
To prevent memory leaks when using FastComments views in Activities or Fragments, always call cleanup() when the view is no longer needed:
@Override
protected void onDestroy() {
super.onDestroy();
// Clean up FastComments views to prevent memory leaks
if (feedView != null) {
feedView.cleanup();
}
if (commentsView != null) {
commentsView.cleanup();
}
}@Override
public void onDestroyView() {
super.onDestroyView();
// Clean up FastComments views when fragment view is destroyed
if (feedView != null) {
feedView.cleanup();
feedView = null;
}
}
@Override
public void onDestroy() {
super.onDestroy();
// Additional cleanup when fragment is destroyed
if (feedSDK != null) {
feedSDK.cleanup();
feedSDK = null;
}
}// Before replacing or removing a fragment containing FastComments views
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.container);
if (currentFragment instanceof YourFragmentWithFeedView) {
((YourFragmentWithFeedView) currentFragment).cleanupFeedView();
}
// Then proceed with fragment transaction
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, newFragment)
.commit();Important: Always call cleanup() methods to prevent memory leaks, especially when:
- Activities are destroyed
- Fragment views are destroyed
- Switching between fragments
- Navigating away from screens with FastComments components
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please contact [email protected] or visit fastcomments.com/auth/my-account/help.