1. Home
  2. Getting Started
  3. Android Quick Start
  1. Home
  2. Developers
  3. Android
  4. Android Quick Start

Android Quick Start

This documentation helps you quickly start using Apptentive in your Android app. For complete documentation, as well as system requirements, see the Android Integration guide.

1. Add Apptentive

In your build.gradle, add a dependency to Apptentive

repositories {
  jcenter()
}

dependencies {
  implementation 'com.apptentive:apptentive-android:5.4.0'
}

When prompted by Android Studio, click Sync Now

2. Register Apptentive

When your app starts, it will need to register Apptentive. This step must happen in your Application class’s onCreate() method.

public class YourApplication extends Application {
    @Override
    public void onCreate() {
      super.onCreate();
      ApptentiveConfiguration configuration = new ApptentiveConfiguration("YOUR_APPTENTIVE_APP_KEY", "YOUR_APPTENTIVE_APP_SIGNATURE");
      Apptentive.register(this, configuration);
    }
}

Make sure you use the Apptentive App Key and Apptentive App Signature for your Android app on the API & Development page. Sharing keys in two apps, or using keys from the wrong platform is not supported, and will lead to incorrect behavior.

3. Styling Apptentive

Apptentive will inherit your app’s styles by default. If you are using a Light/Dark AppCompat theme, Apptentive will look like your app by default, and you can skip this step. But if you are using another theme, or if you want to force Apptentive to adopt different styles than your app, please follow instructions in Android Interface Customization.

4. Add Message Center

Find a place in your app for a button that will launch Message Center. This will allow customers to contact you with feedback, or questions if they are having trouble using your app, as well as allow them to see your responses.

If Message Center is available, show a Button that will launch it when clicked. This example assumes you have an Activity called SettingsActivity that you has a Button you would like to open Message Center with.

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.settings_layout);

  final Button button = (Button) findViewById(R.id.message_center_button);
  Apptentive.canShowMessageCenter(new Apptentive.BooleanCallback() {
    @Override
    public void onFinish(boolean canShowMessageCenter) {
      if (canShowMessageCenter) {
        button.setVisibility(View.VISIBLE);
        button.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
          Apptentive.showMessageCenter(YourActivity.this);
        }
      });
    } else {
      button.setVisibility(View.GONE);
    }
  }
}

5. Add Events

Events record user interaction. You can use them to determine if and when an Interaction will be shown to your customer. At a minimum, you should include around 10 Events in your app to start taking advantage of Apptentive, but for now, let’s just create one. To trigger an Event, call the engage() method. This will record the Event, and then check to see if any Interactions targeted to that Event are allowed to be displayed, based on the logic you set up in the Apptentive Dashboard.

In this example, trigger an Event when your Main Activity resumes.

@Override
protected void onResume() {
  super.onResume();
  Apptentive.engage(this, "main_activity_resumed");
}

6. Show a Survey

Now that you’ve created an Event, you can create a survey and display it when the Event is triggered.

  1. Go to the Surveys page.
  2. Click “New Survey” to create a new survey.
  3. Give the survey a name, title, introduction, add a question, choose whether to end with a Thank You message, and click Save & Continue
  4. Choose Publish survey as an independent Interaction
  5. Under the Where section, chose the Event main_activity_created (or whatever Event name you used). If your app hasn’t connected to the server after triggering that Event, you will need to add it manually at this point, by clicking Create new Event…
  6. Near the bottom, check Allow multiple responses from the same person so you can display this survey more than once.
  7. Click Save & Continue
  8. Click Launch Survey

Now, if you restart your app, you will see this survey when you trigger the main_activity_created Event.

Updated on January 29, 2019

Was this article helpful?

Related Articles