Skip to content

Getting Started

Ryan Matthew Pierson edited this page Jun 18, 2020 · 8 revisions

This quick-start guide will get you up and running with the Khoros Community Android SDK.

Prerequisites

This guide assumes you have:

  • Access to a Khoros Community instance running version 18.4 or later
  • A Community user account with the Manage API Apps permission granted in Community Admin
  • Android Studio

Getting app credentials

To communicate with a Community instance, your app needs to have a client ID and secret. Your app will pass these credentials to your Khoros Community when you initialize the SDK, along with a few other details including your Community URL and your Community tenant ID. You create and manage credentials in Community Admin > System > API Apps.

When creating app credentials in Community Admin, you can also configure:

  • Which discussion styles to support when using the Community Android SDK Support UI
  • The response limit for messages returned by LiQL queries used with the Support UI components
  • Your notification provider and provider key, if using push notifications

Important: Credentials are environment-specific. We recommend generating app credentials in your stage site during development. To point your app at your production community, generate new credentials on your production Community instance, and then click the 'Download' option available next to each API app, a credentials.xml file will be downloaded add that file to /res/values/, (See Initializing the SDK for complete instructions.)

To generate app credentials:

  1. Go to Community Admin > System > API Apps.

  2. Click Create Android App.

  3. Enter a Display Name for your app.

  4. (Optional) If you want to disable either the Forum or Blog discussion styles, uncheck the associated Enabled Discussion Styles checkbox.

  5. (Optional) If desired, change the default Response Limit of items returned from LiQL queries sent by Support UI components. The default is 30 per query. Note that this limit only is only reflected in the UI Support library components. This setting does not affect our core APIs.

  6. (Optional) If using Firebase Cloud Messaging, select the Push Notification Adapter type you are using and add your Push Notification Server Key.

  7. Click Save.

Your new app appears in the API Apps tab. Your credentials, tenant ID, API proxy host, and Community URL are listed next to the app entry. Click Edit to edit the app configuration. Click Delete to delete your app.

Client ID, secret, tenant ID, and proxy host name

Adding the SDK and dependencies to your project

If you haven't already, clone this repository.

The easiest way to add the Community Android SDK to your project is to pull them from JCenter. Simply add jcenter and google to the repositories in the root level build.gradle file, and then add the SDK as a dependency.

While adding jcenter repository do mention the overloaded jcenter declaration with the url - 'https://dl.bintray.com/lithiumtech/lia-sdk-android' otherwise proper binaries will not be imported.

To add JCenter to the build script:

In Android Studio, open the build.gradle file for your Android project (the is the top-level build file). The file should look similar to this:

// Top-level build file where you can add configuration options common to all sub-projects/modules. 
buildscript { 
    repositories {
        jcenter{
            url 'https://dl.bintray.com/lithiumtech/lia-sdk-android'
        } 
        jcenter() 
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        // any other repositories required
    } 
    dependencies { 
        classpath 'com.android.tools.build:gradle:2.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.2.0'
    }
}
 
allprojects {
    repositories {
        jcenter{
            url 'https://dl.bintray.com/lithiumtech/lia-sdk-android'
        }
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        // any other repositories required
    }
}

Add the Community Android SDK packages as dependencies

In Android Studio, open the build.gradle file for your module.

Add the following libraries as dependencies:

* `implementation 'com.lithium.community.android:lia-core:1.3.0'`
* `implementation 'com.lithium.community.android:lia-ui:1.3.0'` (Optional. Only required if you will use the UI Support library.)

The entry should look like this:

```gradle
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.lithium.community.android:lia-core:1.3.0' // add core SDK
    implementation 'com.lithium.community.android:lia-ui:1.3.0' // add UI SDK

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestImplementation 'com.android.support.test:runner:0.5'
}
```

Continue with Initializing the SDK.

Initializing the SDK

In Getting app credentials, we generated a client ID and secret in Community Admin. We need to pass these credentials during app initialization to make the SDK available to your app. This is required to use our core features and our Support UI components.

Initialization steps include:

  • Adding your credentials
  • Adding initialization code

We describe these steps in Initializing the SDK. Follow the instructions there, and then return to this guide.

Start your project

Click Run to build your project.

Next Steps

At this point, you're up and running with the Community Android SDK. Next: