Your app, Powered by EXI Exercise Intelligence
Our personalised physical activity prescription, your app.
Get up and running with SDKs, API keys and integration tools.
Android EXI® SDK Setup Guide
Add EXI® to your applications
Learn how to create an EXI® powered Android application and integrate the EXI® SDK into your products and platforms.
1. Add the EXI® SDK as a dependency
The EXI® SDK is published on the Github Packages artefactory. In order to gain access to the offering, you must have an access token that references the package with at least
read:packages
scope.
- Create a new Android application, choosing your own specifications
- Create a
github.properties
file in the project root and add your Github credentials:gpr.user=YOUR_GITHUB_USER_ID gpr.key=YOUR_SELF_GENERATED_PERSONAL_ACCESS_TOKEN
- Navigate to the
settings.gradle
, add the GitHub packages maven repository dependencydependencyResolutionManagement { // ... other dependencies def githubProperties = new Properties() githubProperties.load(new FileInputStream(file("github.properties"))) repositories { /// ... other repositories maven { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/exiteam/exi-android-sdk") credentials { username = githubProperties['gpr.user'] password = githubProperties['gpr.key'] } } } }
2. Project Setup
Set your API Key
Open your app-level
build.gradle
, and add the following:plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'maven-publish' } apply { plugin 'maven-publish' }
buildTypes { debug { minifyEnabled false buildConfigField "String", "HEADER_X_API_KEY", "\"YOUR_API_KEY_PROVIDED_BY_EXI\"" buildConfigField "String", "domain", "\"YOUR_ORGANISATION_DOMAIN_PROVIDED_BY_EXI\"" buildConfigField "String", "clientId", "\"YOUR_CLIENT_ID_PROVIDED_BY_EXI\"" debuggable true } }
- Still inside your app-level
build.gradle
, and add the following:android { // ... buildFeatures { buildConfig = true } // ... }
- Add the EXI® SDK dependency package (latest version at time of writing: 0.0.36-ALPHA-SNAPSHOT.
dependencies { // ... implementation 'com.exisdk.life:sdk:0.0.36-ALPHA-SNAPSHOT' }
- Create a
YourAppNameApplication
class extending Application (remember to declare name in theAndroidManifest
). CallInitialise
on the staticEXISDK
object, passing an Android context and your API key, received from EXI. An additional boolean value can be passed as a third parameter to indicate if the SDK user wants a mockResponse. When enableMockResponse is enabled, a sample hardcoded response is returned by the SDK, which can be helpful during development, when in offline mode.class YourAppNameApplication : Application(){ override fun onCreate() { super.onCreate() // Initialize SDK EXISDK.initialize(this,BuildConfig.HEADER_X_API_KEY) } }
3. Set your JWS Token
Create your JWT token
Using the following links: Online JWS key generator & JWT.IO .
Generate JWS credentials: Online JWS key generator
- Choose the
RS256
algorithm- Save all credentials somewhere safe
- Open JWT.IO and paste your credentials to verify signature
- You can use this website and credentials to easily change the payload and get a new token quickly
You must encrypt the details provided to you by EXI®. These include:
organisationId
(your organisation ID)userId
(your userId)exp
(a token expiry value)
4. Start your development journey with EXI®
Please note: The EXI Android SDK uses Kotlin Coroutines for its threading model, and so all functions are suspend functions. Coroutines give the developer the ability to start light-weight threads that may suspend the execution of a block of code from any given thread, and run asynchronously away from the UI thread. They can block either the main thread or another thread, or they can run concurrently, in parallel.
Sample SDK call for fetching all activities of high intensity
GlobalScope.launch { when(val allActivities = EXISDK().getAllActivities("HIGH")) { is Result.Success -> { Log.d(javaClass.simpleName, allActivities.data.toString()) } is Result.Error -> { Log.d(javaClass.simpleName, allActivities.error.message) } } } }
Result
[EXIActivity( id=21e9f3f1-fab1-4440-8d81-eb6f3face177, name=Bodyweight workout), EXIActivity(id=217f5fe0-d922-4092-afaa-0350c52b88a2, name=Cardio blast), EXIActivity(id=d7b977ad-703e-4c91-b632-472eead1b6e9, name=Aerobics with Hayley), EXIActivity(id=de59f557-766f-4b36-9add-2a1791dad893, name=Power and strength), EXIActivity(id=abb14514-24e2-4389-9e5f-eeca15fb72ad, name=HIIT), EXIActivity(id=4f814dcb-aabb-4b9b-9cc1-4ea7b592ea76, name=Power and core), EXIActivity(id=05720979-6f59-4c39-972a-c2ee0dcc1efb, name=Circulation boost), EXIActivity(id=09b660b9-1ee4-4586-9e44-f664073b1b52, name=Other exercise), EXIActivity(id=137efb32-197d-4496-b040-52f4d506947f, name=Swimming), EXIActivity(id=47239873-949f-48a9-b525-12d91bd94297, name=Step machine), EXIActivity(id=7393b3ce-958c-401d-a5ef-ba9602ba59be, name=Outdoor cycle), EXIActivity(id=7773fa77-c136-4aa3-b1f4-0e7fdb8e5388, name=Outdoor run), EXIActivity(id=926365dc-5201-4040-b2f4-dde1844bf884, name=Treadmill run), EXIActivity(id=95a3cf02-2ae4-4acd-9544-9ed2174ae938, name=Treadmill walk), EXIActivity(id=d6169d39-e1e8-4232-aaea-e69028dc7e6d, name=Rowing machine), EXIActivity(id=de648095-edf4-4ae5-8953-920df55a6715, name=Indoor cycle), EXIActivity(id=7f7e80bd-a5df-42f7-a1d7-60f6bdcdf782, name=Andy Test High Activity )]
You are now ready to build your customer health journeys!
Please consult our Android developer code docs and our UML Diagram repository to discover what is possible with EXI® SDK.