Android Story Quick Start Guide

Quick Start Guide for Integrating AmityUIKit's Story Feature into Android Applications

Welcome to the Quick Start Guide for integrating Amity Social Cloud's Story feature into your existing Android application. This guide provides step-by-step instructions to incorporate social storytelling into your app, enhancing user engagement through shared experiences.

Prerequisites

  1. Android Studio installed on your system.

  2. An Android project targeting API level 21 (Android 5.0) or higher.

  3. A valid Amity Social Cloud account and an API key.

Step 1: Prepare Your Android Project

Ensure your project targets Android 5.0 (API Level 21) or above in your build.gradle (Module) file:

android {
    ...
    defaultConfig {
        minSDKVersion 21 // Minimum support is API level 21
    }
}

Step 2: Add JitPack Repository

Add the JitPack repository to your project-level build.gradle file to access AmityUIKit:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 3: Add AmityUIKit Dependency

Insert the dependency for AmityUIKit in your app-level build.gradle file. Ensure to replace x.y.z with the latest version:

dependencies {
    implementation 'com.github.AmityCo.Amity-Social-Cloud-UIKit-Android:amity-uikit:x.y.z'
}

Step 4: Configure Gradle Settings

Enable data binding, set the Java and Kotlin compatibility versions in your app-level build.gradle:

android {
    ...
    buildFeatures {
        dataBinding = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

Step 5: Manage Conflicting File Generation

To avoid build errors related to conflicting files, add these lines to your app-level build.gradle:

android {
    ...
    packagingOptions {
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
}

Step 6: Initialize AmityUIKit SDK

Initialize the SDK with your API key before using any of its features:

AmityCoreClient.setup("Your_API_Key")

Optionally, specify endpoints manually if required by your application's infrastructure needs.

Step 7: Integrating Story Feature

For integrating the story feature into your Android application, you can use Jetpack Compose for a modern and efficient UI implementation.

  • For displaying stories related to a specific community:

@Composable
fun DisplayStoryTargetTab(community: AmityCommunity) {
    AmityStoryCommunityTargetTabComponent(communityId = community.getCommunityId())
}
  • For navigating to the story creation page, specifying a target community ID:

To allow users to create stories, initiate the story creation page with a specific target, such as a community ID:

fun startStoryCreationActivity(context: Context, communityId: String) {
    val intent = Intent(context, AmityCreateStoryPageActivity::class.java).apply {
        putExtra("communityId", communityId)
    }
    context.startActivity(intent)
}

Step 8: Customizing the UI

AmityUIKit supports extensive customization options via a config.json file. You can modify themes, colors, and icons for various components and elements of the story feature according to your application's design requirements.

  • Example customization snippet:

"global_theme": {
  "light_theme": {
    "primary_color": "#FFFFFF",
    "secondary_color": "#AB1234"
  }
}
  • You can exclude certain UI elements or customize specific components and elements as per your needs.

You have now successfully integrated the Amity Social Cloud Story feature into your Android application. For further customization options, refer to the detailed documentation provided with the SDK. If you encounter any issues or require assistance, our community forum at community.amity.co is always here to help.

Last updated