Quickstart

Integrate our SDK in your android app.

Step 1 : Install SDK

Install the SDK to your project via Gradle in Android Studio and add the dependencies below in your app build.gradle file.

android {
.....
defaultConfig{
targetSdkVersion 28
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
......
}
dependencies {
implementation 'com.geospark.android:geospark:2.0.0'
}

Step 2: Initialize SDK

Initialize the SDK with your PublishKey.

//In onCreate method of your Application class include the code below.
public void onCreate() {
super.onCreate();
GeoSpark.initialize(this, "PUBLISH_KEY");
...
}

Step 3: Create user

GeoSpark SDK needs a User ID object to identify the device.

GeoSpark.createUser(this,"User Description", new GeoSparkCallBack() {
@Override
public void onSuccess(GeoSparkUser geoSparkUser) {
geoSparkUser.getUserId();
}
@Override
public void onFailure(GeoSparkError geoSparkError) {
geoSparkError.getErrorCode();
geoSparkError.getErrorMessage();
}
});

Step 4: Start Location Tracking

To start tracking the location.

//To enable location, call the requestLocationPermissions and
//requestLocationServices method.
if(!GeoSpark.checkLocationPermission(this)) {
GeoSpark.requestLocationPermission(this);
} else if (!GeoSpark.checkLocationServices(this)) {
GeoSpark.requestLocationServices(this);
} else{
//Call this method to start tracking the location.
GeoSpark.startTracking(this);
}