Android SDK basic integration

Once you have plugged in the Android SDK, call a few simple SDK methods to start seeing live location of your users on HyperTrack dashboard. You'll begin to see trips that the user makes (along with polylines, time & distance traveled) and places that the user stops at (along with time they spend at that place).

In case you are not using Android, you can refer to the iOS or React Native versions.

[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: Create SDK user

To be able to identify the device, the SDK needs a user id. You can create a new user user on the SDK, and specify user's name, phone and a unique lookup_id as string identifiers. This API is a network call that requires the device to be online.

[info] User already created?

You can set an existing user id, in case you have created an user id via the backend API using the HyperTrack.setUserId("YOUR_USER_ID") method in the SDK.

SDK method Description
getOrCreateUser Creates a new user, or fetches an existing user with the same lookup id.
setUserId Set the user id if the user has been created on the backend.
UserParams = new UserParams().setName(name)

// This API will create a new user only if none exists already for the given lookup_id
HyperTrack.getOrCreateUser(userParams, new HyperTrackCallback() {
    public void onSuccess(@NonNull SuccessResponse successResponse) {
        if (response.getResponseObject() != null) {
            User user = (User) response.getResponseObject();
            // Handle user_id, if needed
            String userId = user.getId();

            Toast.makeText(this, "User created successfully with UserId: " + userId, Toast.LENGTH_SHORT).show();

    public void onError(@NonNull ErrorResponse errorResponse) {
        // Handle createUser error here
       Toast.makeText(this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();

Step 2: Start the SDK

To start tracking the user, use the startTracking method. You can keep the SDK on throughout the day, or turn it off if you want to stop tracking the user at any point of time using the HyperTrack.stopTracking() method.


Step 3: View dashboard

Install your app with the HyperTrack SDK on a device and begin tracking on the Dashboard. You would see the user’s current state on the HyperTrack dashboard. If you click on the user, you should be able to view the user's trips and stops.

Real-time support

GCM/FCM integration with HyperTrack SDKs enables realtimeness in tracking experiences across platforms. This allows the SDK to be controlled by the server for better battery optimization and also adds robustness in recovering from crashes.

[info] Realtime support Onboarding

We recommend you try our new interactive step-by-step onboarding to enable realtime support. Refer here for more details or in case of any issues.

Android Realtime support Onboarding

Step 4: Stop the SDK

To stop tracking the user, use the stopTracking method.


Simulate a trip for testing

To simulate a trip, replace startTracking API with startMockTracking and stopTracking API with stopMockTracking.

[info] Simulate where?

startMockTracking API will run a simulation from your current location to a nearby location. You can stop this simulation anytime by calling stopMockTracking API.

// Replace startTracking API with startMockTracking
// HyperTrack.startTracking();
HyperTrack.startMockTracking(new HyperTrackCallback() {
    public void onSuccess(@NonNull SuccessResponse response) {
        // Handle startMockTracking success here

    public void onError(@NonNull ErrorResponse errorResponse) {
        // Handle startMockTracking error here
        Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
// Replace stopTracking API with stopMockTracking
// HyperTrack.stopTracking();

Sample References

Check out our open-sourced live location sharing and at-home service visit repositories for detailed reference.

[success] Basic Integration Completed

Now that we have the basic integration complete, lets see how we can use actions to build your use cases.

results matching ""

    No results matching ""