Self-Managed Integration

Once the SDK is initialized, you can start tracking locations and use the data locally on your device or send it directly to your own backend server.

Location Tracking

Once the tracking mode is configured, use the below code to start tracking.

Kotlin
Java
Kotlin
GeoSpark.startSelfTracking(trackingMode)
Java
GeoSpark.startSelfTracking(trackingMode);

You may see a delay if the user's device is in low power mode or has connectivity issues.

To listen to location updates create a class that extends GeoSparkReceiver. Then register the receiver by adding a receiver element to the application element in your manifest.

<application>
...
<receiver android:name=".MyGeoSparkReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.geospark.android.RECEIVED"/>
</intent-filter>
</receiver>
...
</application>

Then add the code to the receiver.

Kotlin
Java
Kotlin
class MyGeoSparkReceiver : GeoSparkReceiver() {
override fun onLocationUpdated(context: Context?, geosparkLocation: GeoSparkLocation?) {
// receive own location updates here
// do something with location data using location
}
}
Java
public class MyGeoSparkReceiver extends GeoSparkReceiver {
@Override
public void onLocationUpdated(Context context, GeoSparkLocation geosparkLocation) {
// receive own location updates here
// do something with location data using location
}
}

To stop the tracking use the below method.

Kotlin
Java
Kotlin
GeoSpark.stopSelfTracking()
Java
GeoSpark.stopSelfTracking();

Location Tracker

Location update payload objects that you can receive with the location tracker:

Key

Type

Description

latitude

Float

Geographic coordinate north-south

longitude

Float

Geographic coordinate west-east

speed

Float

Speed in kilometers per hour (only in motion)

altitude

Float

Height above the sea level in meters

horizontal_accuracy

Float

Horizontal accuracy of the coordinates

vertical_accuracy

Float

Vertical accuracy of the coordinates

activity

String

Is the user moving or did they stop?

recorded_at

Datetime

Location recorded at timestamp in UTC

tz_offset

String

Location recorded at timezone