The Reimagined Trailblazer Community is Here! Learn More.

Build a Hello World App for Android

Learning Objectives

After completing this unit, you’ll be able to:
  • Embed the Service SDK frameworks into your Android project.
  • Wire up some basic Service SDK features to your Android project.
  • Describe where to find more Service SDK resources.

Get Started with Android

In this unit, we show you how quickly you can connect Service Cloud features to your existing Android app. It’s a bit different with the Android Service SDK than the iOS Service SDK. That’s because we’ve developed each SDK to follow the standard design patterns for each platform.



This unit assumes that you’re familiar with Android development. We’re not going to teach you how to write Java code or how to get around the Android Studio IDE. If you’re not familiar with these things, you can still scan the unit to get a feel for what it entails to use this SDK.

Create a Basic Project in Android Studio

Let’s create a phone project with Android Studio. Be sure to specify a Minimum SDK of API 21 or above.

Android studio setup

Also, let’s make a Basic Activity project, so that we get a floating action button (FAB) for free.

Basic activity project

Now we’re cooking. To bring in the SDK into our project, we need to update the repositories in the build.gradle script:

allprojects {
  repositories {
    maven {
      url ''
    maven {
      url ''

And update the dependencies in the app’s build.gradle script:

dependencies {
  compile 'com.salesforce.service:servicesdk:+'


It is best to compile against a specific version of the SDK. Replace the "+" with the specific version you want to use. Check out the installation instructions for version information (see Resources).

Before we get to the code, let’s change the FAB from an email icon ( ic_dialog_email) to a help icon ( ic_menu_help). You can change this from activity_main.xml:


Things are looking good so far. Now let’s add some code to this project so it does something interesting…

Let’s Get Coding…Android Style

In this unit, we’re once again going to hook into the Knowledge feature, but you can try any of the other features if you prefer.

First define some variables in our main Activity class.

// You should normally maintain a reference to these instances
// within the Application lifecycle (rather than Activity lifecycle)...
// They are placed here just for this example...
KnowledgeUI mKnowledgeUI = null;
KnowledgeUIClient mKnowledgeUIClient = null;
// Specify the site url, category group, and root category
public static final String siteUrl = "https://your-site-url";
public static final String categoryGroup = "your-category-group";
public static final String rootCategory = "your-root-category";

Like with the iOS unit, be sure to replace the placeholder values with real values for your Experience Cloud site, data category group, and root data category. Check out Cloud Setup for Knowledge in the Resources section for detailed guidance.

And now let’s create an initialize method and a start method for Knowledge.

// Call this method at init time...
private void initKnowledge() {
    if (mKnowledgeUI == null) {
        // Create a core configuration instance
        KnowledgeConfiguration coreConfiguration =
        // Create a UI configuration instance from core instance
        KnowledgeUIConfiguration uiConfiguration =
            KnowledgeUIConfiguration.create(coreConfiguration, categoryGroup, rootCategory);
        // Create a UI instance
        mKnowledgeUI = KnowledgeUI.configure(uiConfiguration);
// Call this method when you want to show the Knowledge UI
private void startKnowledge() {
    if (mKnowledgeUIClient == null) {
        // Create a client asynchronously
            .onResult(new Async.ResultHandler<KnowledgeUIClient>() {
            @Override public void handleResult (Async<?> operation,
                KnowledgeUIClient uiClient) {
                // Store reference to the Knowledge UI client
                mKnowledgeUIClient = uiClient;
                // Handle the close action
                uiClient.addOnCloseListener(new KnowledgeUIClient.OnCloseListener() {
                    @Override public void onClose () {
                        // Clear reference to the Knowledge UI client
                        mKnowledgeUIClient = null;
                // Launch the UI

The initKnowledge method uses configuration information to build a KnowledgeUI object. The startKnowledge method creates a KnowledgeUIClient from the KnowledgeUI object and then launches the interface with the SDK method, launchHome.

We can wire up the initKnowledge method to the onCreate method and the startKnowledge method to where the user taps the FAB. Something like this:

protected void onCreate(Bundle savedInstanceState) {
    Toolbar toolbar = (Toolbar) findViewById(;
    FloatingActionButton fab = (FloatingActionButton) findViewById(;
    fab.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {

And that does it. Launch the app in the emulator, tap the FAB, and watch Knowledge appear.

Knowledge on Android

Like with iOS, this is just the beginning. You can add hero images and customize the colors to match your brand. You can build an entire support home experience that includes Knowledge, Case Management, and Chat. And if you prefer, you can write your own UI and tap into our lower-level API.

What’s Next?

Check out the Resources section for links to handy documentation to take your service-enabled apps to the next level. You can start with the Embedded Service SDK for Android Developer Guide. It contains more tutorials, more examples, and covers loads more topics. It gives you all you need to connect up the major support features: Knowledge, Case Management, and Chat. You can also refer to the Reference Documentation for Android for those nitty-gritty details about the API.

So there you have it—an introduction to the Embedded Service SDK for Mobile Apps. By now, you understand the value of this toolkit and have a feeling for what it’s like to use it. Lots of features, without much coding required. So now it’s your turn. Let’s see what you can do with this SDK!

Keep learning for
Sign up for an account to continue.
What’s in it for you?
  • 1 in 4 land a new job
  • 50% receive a promotion or raise
  • 80% learn new technologies that boost their resume
  • 66% say it increases productivity
Source: Trailblazer Community Impact Survey 2019