Add the Android SDK

Follow these steps to add the Android SDK to your application.
  1. Add permissions.
    Add these permissions to the AndroidManifest:
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    Note: In addition to updating the AndroidManifest, you must prompt users to accept these permissions before starting the SDK. For more information, see Request runtime permissions.
  2. Modify root-level.

    Make these changes in the project (root-level) build.gradle or settings.gradle:

    Important: The build.gradle or settings.gradle file is in the project's root folder. Its configuration settings apply to every module in the project.
    repositories {
      maven { 
        url = uri("https://repository.medallia.com/artifactory/sense360-android-sdk/")
      }
    }                        
    repositories {
      maven { 
        url "https://repository.medallia.com/artifactory/sense360-android-sdk/" 
      }
    }                   

    If you need to migrate from the Sense360 repository to the Medallia repository, see Migrate the Sense360 repository.

  3. Modify app-level.

    Make these changes in the module (app-level) build.gradle to add this SDK to your dependencies list:

    Important: This build.gradle file is in the app folder. Its build settings apply only to the app module.
    implementation("com.medallia:sense360-android-sdk:$sense360_sdk_version") {
        exclude(group =  "org.json", module = "json")
    }                        
    implementation("com.medallia:sense360-android-sdk:$sense360_sdk_version"){     
        exclude group: 'org.json', module: 'json'
    }
    Note: Replace $sense360_sdk_version with the current version of the SDK.

    If you need to migrate from the Sense360 repository to the Medallia repository, see Migrate the Sense360 repository.

  4. Implement Sense360.start().
    Add this line in an appropriate place in your application's startup lifecycle. The start() call below should be located to be called every time the application launches, as well as immediately after location permissions have been granted. This ensures that the SDK:
    • Starts after the user has enabled location permissions.
    • Re-starts every time the app is launched or opened.

    Place the call to Sense360.start() within your application's MainActivity's onStart() method.

    Sense360.start(getApplicationContext(), BuildConfig.DEBUG);
    Sense360.start(applicationContext, BuildConfig.DEBUG)

    Set BuildConfig.DEBUG to true when testing the app before releasing (unit, integration, automation, or any other tests), and false when released to the Google Play Market.

    Typically, Sense360 uses this application BuildConfig.DEBUG value as it turns automatically to false on release build. If you do not have this variable, provide the appropriate value. The Sense360.start() method returns an int, which is the result code of starting the SDK.

    These are the possible return values:

    0 - Started successfully.
    1 - An exception occurred while executing start method.
    2 - Android version is less than API 28.
    3 - SDK is in permanently stopped state. This means that Sense360.userOptOut was called before. Call Sense360.userOptIn.
    4 - SDK was deactivated remotely. Contact Sense360.
    5 - Google Play Services is outdated or unavailable.
    6 - Location permission is not granted.
    8 - Error in generating User Id.
    9 - Issue with generating dates on device. Try another device.
    10 - Running on unsupported Android OS version.
    11 - User opted out of data collection. Uninstall and re-install application to wipe user information.
    12 - Bad Area: SDK has detected international travel and is disabled for 1 week.
    13 - Invalid more info activity provided for the foreground service notification.
    14 - Invalid custom launch activity provided for the foreground service notification.
    Note: To ensure that the SDK has started successfully, check for this value to be 0 on first run. This line is printed in logcat when the SDK starts successfully:

    ServiceController: Starting Sense360 {SDK_VERSION} for user 18a18b1d-1f61-1e10-abb1-4c1d12bc11bb

You have now added the Sense360 Android SDK.