Android SDK Setup

To use HyperTrack SDK in your Android app, we first need to plug in the SDK into your app.

[info] Step-By-Step Onboarding

Setting up HyperTrack Android SDK in your app?

We recommend you try our new interactive step-by-step onboarding

Android Onboarding

 

[warning] Requirements

The SDK is compatible with Android 4.1 (API level 16) and above. Also, the SDK can only be used in devices that support GPS. Devices utilizing only A-GPS are not supported.

Step 1: Install the SDK

In your app's build.gradle file, define the repositories and dependencies as shown. Once configured, run a gradle sync to import the SDK and its dependencies to your project.

In case you're facing Gradle dependency conflict errors, refer here for detailed info.

[info] build.gradle files

Your project will have two gradle files: one for the app module, and one for the project. Edit the app module file to install the SDK.

repositories {
    maven {
      url "http://hypertrack-android-sdk.s3-website-us-west-2.amazonaws.com/"
    }
}

dependencies {
    compile("com.hypertrack:android:0.2.8:release@aar") {
        transitive = true;
    }
}

[warning] Proguard rules

If you are using Proguard in your project add the following lines to your proguard configuration file (proguard-rules.pro):

  • -keep class com.hypertrack.lib.** { *; }
  • -dontwarn com.hypertrack.lib.**

Step 2: Configure the SDK

Now that the SDK has been installed, you can use the SDK methods inside Android Studio. Configure your publishable key and initialise the SDK in the onCreate method of your Application class.

HyperTrack.initialize(this.getApplicationContext(), “YOUR_PUBLISHABLE_KEY”);

Step 3: Enable location permissions

  • The SDK requires the ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions. These are already included in the SDK manifest so need not be explicitly added.

  • In case your app is for Marshmallow and above (API level 23+), Call requestPermissions() API to request for run-time location permissions.

  • For high quality location collection, the SDK needs location services enabled at high accuracy. Call requestLocationServices() API to request for user to enable Location Services in high-accuracy, if not enabled already.

Refer here for a sample implementation for requesting Location Permissions & Services.

// To request Location Permissions
HyperTrack.requestPermissions(this);

// To enable Location Services
HyperTrack.requestLocationServices(this, null);

[success] Setup SDK Completed

Now that we have the SDK plugged-in in your app, lets do a basic integration.

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""