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.

[info] Step-By-Step Onboarding

Integrating 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: 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.

// This API will create a new user only if none exists already for the given lookup_id
HyperTrack.getOrCreateUser(userName, phone, lookupId, new HyperTrackCallback() {
    @Override
    public void onSuccess(@NonNull SuccessResponse response) {
         if (response.getResponseObject() != null) {
            User user = (User) response.getResponseObject();
            String userId = user.getId();
            // Handle user_id, if needed
            Toast.makeText(this, "User created successfully with UserID: " + userId, Toast.LENGTH_SHORT).show();
            ...
        }       
    }

    @Override
    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.

HyperTrack.startTracking();

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.

Step 4: Stop the SDK

To stop tracking the user, use the stopTracking method.

HyperTrack.stopTracking();

Step 5: 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.

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""