Utility methods

Last updated 13 days ago

Repository of all the available SDK methods in the Movement SDK for Android

Initializing the SDK

Initialize the HyperTrack SDK by calling this method once from the onCreate method of either your Application file or your app's Launcher activity.

HyperTrackCore.initialize(Context context, String publishableKey);

Parameters

Name

Type

Description

context

Context

Pass your application context

publishableKey

String

Account's publishable key

Check location permission

Check whether your app has location permission. Returns a boolean, which is true if the location permission has been granted, and false otherwise.

HyperTrackCore.checkLocationPermission(Context context);

Parameters

Name

Type

Description

context

Context

Application's Context

Returns

Type

Description

Bool

true if the location permission has been granted, false otherwise

Check location services

Check whether the device has location services enabled. Returns a boolean, which is true if the location location services is ON, and false otherwise.

HyperTrackCore.checkLocationServices(Context context);

Parameters

Name

Type

Description

context

Context

Application's Context

Returns

Type

Description

Bool

true if the location services has been enabled, false otherwise

Request location permissions

Call this method to request user to enable location permissions.

HyperTrackCore.requestLocationPermissions(@NonNull Activity activity,
final LocationPermissionCallback callback)

Parameters

Name

Type

Description

activity

Activity

Instance of the activity where permission needs to be requested.

callback

LocationPermissionCallback

Callback to know wether the user has given or denied permissions

Pause tracking

Stops the SDK from listening to user's movement updates and recording any data. If this method is called, the SDK will not resume movement tracking until resumeTracking() method is called.

HyperTrackCore.pauseTracking();

Resume tracking

Allows the SDK to resume a previously paused tracking. Call this method when you had previously made a call to pauseTracking() method. While setting up the SDK, you don't need to explicitly call this method. The SDK will automatically start recording data as soon as it receives the required permissions.

HyperTrackCore.resumeTracking();

Get device id

Get device id generated by HyperTrack for this device. You may want to map this device id to the user id in your system, and send this mapping to your server. The method returns a string containing the Device ID if the SDK has been initialized, null otherwise.

HyperTrackCore.getDeviceId()

Returns

Type

Description

String

A unique identifier for the device

Add device name & metadata

Add/edit a name and metadata to deviceID. Helps you identify the device on HyperTrack dashboard.

String name = "Alex";
HashMap<String, Object> metadata = new HashMap<>();
metadata.put("customer_id", 505054);
metadata.put("vehicle", "car");
HyperTrackCore.setNameAndMetadataForDevice(name, metadata)

Parameters

Name

Type

Description

name

String

Name that you want to see on the HyperTrack dashboard. Could be name of the user

metadata

Hashmap

Tuple of label and value

Customize notification

HyperTrack runs as a foreground service. This leads to a persistent notification in the status bar. You can customize small icon, large icon, title and body in this persistent notification.

HypertrackCore.addNotificationIconsAndTitle(
int smallIconId,
int largeIconId,
String title,
String body
)

Name

Type

Description

smallIconID

Integer

Resource id for small icon of notification

largeIconID

Integer

Resource id for large icon of notification

title

String

Title of notification

body

String

Body of notification