Add the Android SDK
- 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 theAndroidManifest
, you must prompt users to accept these permissions before starting the SDK. For more information, see Request runtime permissions. - Modify root-level.
Make these changes in the project (root-level)
build.gradle
orsettings.gradle
:Important: Thebuild.gradle
orsettings.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.
- Modify app-level.
Make these changes in the module (app-level)
build.gradle
to add this SDK to your dependencies list:Important: Thisbuild.gradle
file is in theapp
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.
- Implement
Sense360.start()
.Add this line in an appropriate place in your application's startup lifecycle. Thestart()
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'sonStart()
method.Sense360.start(getApplicationContext(), BuildConfig.DEBUG);
Sense360.start(applicationContext, BuildConfig.DEBUG)
Set
BuildConfig.DEBUG
totrue
when testing the app before releasing (unit, integration, automation, or any other tests), andfalse
when released to the Google Play Market.Typically, Sense360 uses this application
BuildConfig.DEBUG
value as it turns automatically tofalse
on release build. If you do not have this variable, provide the appropriate value. TheSense360.start()
method returns anint
, 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 be0
on first run. This line is printed inlogcat
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.