Android SDK method references

HyperTrack Event & Error Callback

HyperTrack SDK sends periodic events according to user's timeline while he is being tracked. In order to capture these events or handle the errors in-app, call HyperTrack.setCallback method to set a HyperTrackCallback which allows you to receive these events and errors happening in the HyperTrackSDK as they occur.

Event Type Description
STOP_STARTED_EVENT Event indicating user has stopped at a Place.
STOP_ENDED_EVENT Event indicating user is on the move and his/her last stop has ended.
TRACKING_STARTED_EVENT Event indicating user's tracking has been started.
TRACKING_STOPPED_EVENT Event indicating user's tracking has been stopped.
ACTION_ASSIGNED_EVENT Event indicating user has been assigned an Action using createAndAssignAction API.
ACTION_COMPLETED_EVENT Event indicating an Action has been completed using completeAction API.
LOCATION_CHANGED_EVENT Event indicating user's location has been updated.
HyperTrack.setCallback(new HyperTrackEventCallback() {
    @Override
    public void onEvent ( @NonNull final HyperTrackEvent event){
        switch (event.getEventType()) {
            case HyperTrackEvent.EventType.STOP_STARTED_EVENT:
                //Write your logic here
                break;
                ...
        }
    }
    ...
}
Error Type Code
PUBLISHABLE_KEY_NOT_CONFIGURED 100
SDK_NOT_INITIALIZED 101
USER_ID_NOT_CONFIGURED 102
PLAY_SERVICES_UNAVAILABLE 103
PERMISSIONS_NOT_REQUESTED 104
LOCATION_SETTINGS_DISABLED 105
LOCATION_SETTINGS_LOW_ACCURACY 106
NETWORK_CONNECTIVITY_ERROR 107
INVALID_LOCATION_RECEIVED 121
GET_CURRENT_LOCATION_TIMED_OUT 122
UNHANDLED_ERROR 151
HyperTrack.setCallback(new HyperTrackEventCallback() {
    ...
    @Override
    public void onError(@NonNull final ErrorResponse errorResponse) {
        // Handle HyperTrack SDK errors here
        Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(),
                Toast.LENGTH_SHORT).show();
    }
}

Additional Methods

Method Returns Description
HyperTrack.checkLocationPermission(Context) boolean Returns true if Location permission has been granted to the app, false otherwise.
HyperTrack.requestPermissions(Activity) --- Prompts user to grant Location Permission to the app.
HyperTrack.checkLocationServices(Context) boolean Returns true if Location services have been enabled, false otherwise.
HyperTrack.requestLocationServices(AppCompatActivity, HyperTrackCallback) --- Prompts user to enable Location Services.
HyperTrack.enableMockLocations(boolean) --- Enable Mock locations in the SDK. They are DISABLED by default.
HyperTrack.isTracking boolean Returns true if the user is active currently i.e. startTracking has been called.
HyperTrack.getSDKVersion String Returns SDK's version name casted as a String.

Refer here for a sample implementation for requesting Location Permissions & Services.

Get Current Location

HyperTrack.getCurrentLocation API allows you to fetch device's current location. Only requirement for this API is the SDK to be initialized and Location Settings to be enabled.

HyperTrack.getCurrentLocation(new HyperTrackCallback() {
    @Override
    public void onSuccess(@NonNull SuccessResponse response) {
        // Handle getCurrentLocation API success here      
        Location location = (Location) response.getResponseObject();   
        ...
    }

    @Override
    public void onError(@NonNull ErrorResponse errorResponse) {
        // Handle getCurrentLocation API error here
        Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), 
                Toast.LENGTH_SHORT).show();
    }
});

Get GNSS Measurements

Call HyperTrack.setGnssStatusCallback API to set an instance of GnssStatus.Callback. This callback will be invoked on every gnss measurement update and the raw gnss measurements can be retrieved in the onSatelliteStatusChanged() method casted as GnssStatus.

HyperTrack.setGnssStatusCallback(new GnssStatus.Callback() {
    @Override
    public void onStarted() {
        super.onStarted();
        // Handle onStarted method here
        ...
    }

    @Override
    public void onStopped() {
        super.onStopped();
        // Handle onStarted method here
        ...
    }

    @Override
    public void onFirstFix(int ttffMillis) {
        super.onFirstFix(ttffMillis);
        // Handle onStarted method here
        ...
    }

    @Override
    public void onSatelliteStatusChanged(GnssStatus status) {
        super.onSatelliteStatusChanged(status);
        // Handle onStarted method here
        ...
    }
});

Tracking View

Customization

HyperTrackMapAdapter provides customization for UI elements in tracking view, you need to create a class extending HyperTrackMapAdapter. This HyperTrackMapAdapter class instance then needs to be set using the HyperTrackMapFragment.setHTMapAdapter() method.

Method Returns Description
getMapPadding(HyperTrackMapFragment hyperTrackMapFragment) int[] To set default padding (left, top, right, bottom) for Map View in HyperTrackMapFragment.
setMyLocationEnabled(HyperTrackMapFragment hyperTrackMapFragment) boolean To display Google Map's MyLocation Marker on the MapView.
setMyLocationButtonEnabled(HyperTrackMapFragment hyperTrackMapFragment) boolean To display Google Map's MyLocationButton on the MapView.
getResetBoundsButtonIcon(HyperTrackMapFragment hyperTrackMapFragment) int To provide a Custom Icon to the Reset bounds button.
getToolbar(HyperTrackMapFragment hyperTrackMapFragment) Toolbar To provide the instance of Toolbar where title & subtitle will be updated with Action statuses & sub-statuses.
getToolbarLogoIcon(HyperTrackMapFragment hyperTrackMapFragment) Integer To provide the instance of Toolbar where title & subtitle will be updated with Action statuses & sub-statuses.
showHeroMarkerForActionID(HyperTrackMapFragment hyperTrackMapFragment, String actionID) boolean To Show/Hide the Hero Marker for an action.
showExpectedPlaceMarkerForActionID (HyperTrackMapFragment hyperTrackMapFragment, String actionID) boolean To Show/Hide the Expected Place Marker for an action.
showMultipleActionsExpectedPlaceMarker(HyperTrackMapFragment hyperTrackMapFragment) boolean To Show Expected Place Marker for common layout while tracking Multiple Actions.
getMultipleActionsExpectedPlaceMarkerIcon(HyperTrackMapFragment hyperTrackMapFragment) int To provide a Custom Icon for common Expected Place Marker while tracking Multiple Actions.
getMultipleActionsExpectedPlaceMarkerView(HyperTrackMapFragment hyperTrackMapFragment) View To provide a Custom View for common Expected Place Marker while tracking Multiple Actions.
getActionSummaryStartMarkerIconForActionID(HyperTrackMapFragment hyperTrackMapFragment, String actionID) int To provide a Custom Icon to the ActionSummaryStart Marker.
getActionSummaryEndMarkerIconForActionID(HyperTrackMapFragment hyperTrackMapFragment, String actionID) int To provide a Custom Icon to the ActionSummaryEnd Marker.
showTrafficLayer(HyperTrackMapFragment hyperTrackMapFragment) boolean To Show the Traffic Layer on hyperTrackMapFragment.
getTrailingPolylineColor int To set the color of trailing polyline when action is active.
getSummaryPolylineColor int To set the color of summary polyline when action has completed.

Callbacks

MapFragmentCallback class in SDK helps you to get callback on various events which happen on HyperTrackMapFragment, you need to instantiate an implementation of the class MapFragmentCallback. This instance then needs to be set using the HyperTrackMapFragment.setMapFragmentCallback() method.

Method Description
onMapReadyCallback(HyperTrackMapFragment hyperTrackMapFragment, GoogleMap map) Invoked when the map.onMapReady Callback is received with the google map instance which will be added in HyperTrackMapFragment
onMapLoadedCallback(HyperTrackMapFragment hyperTrackMapFragment, GoogleMap map) Invoked when the map.onMapLoaded Callback is received with the google map instance which is being loaded in HyperTrackMapFragment
onMapClick(HyperTrackMapFragment hyperTrackMapFragment, GoogleMap map) Invoked when the map.onMapClickListener Callback is received with the google map instance which is being loaded in HyperTrackMapFragment
onMapMyLocationButtonClick(HyperTrackMapFragment hyperTrackMapFragment, GoogleMap map) Invoked when the map.onMyLocationButtonClickListener Callback is received.
onMapMyLocationButtonClick(HyperTrackMapFragment hyperTrackMapFragment, GoogleMap map) Invoked when the map.onMyLocationButtonClickListener Callback is received.
onMapWillClear(HyperTrackMapFragment hyperTrackMapFragment, GoogleMap map) Invoked before map.clear() will be called.
onHeroMarkerAdded(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker heroMarker) Invoked when the hero marker is added.
onHeroMarkerClicked(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker heroMarker) Invoked when the Hero Marker is clicked for a action.
onHeroMarkerWillMove(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker heroMarker, LatLng toLocation) Invoked when the Hero Marker will move on the map.
onHeroMarkerRemoved(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker heroMarker) Invoked when the Hero Marker is removed.
onSourceMarkerAdded(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker sourceMarker) Invoked when the Source Marker is added.
onSourceMarkerClicked(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker sourceMarker) Invoked when the Source Marker is clicked.
onSourceMarkerRemoved(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker sourceMarker) Invoked when the Source Marker is removed.
onExpectedPlaceMarkerAdded(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker expectedPlaceMarker) Invoked when the ExpectedPlace Marker is added.
onExpectedPlaceMarkerClicked(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker expectedPlaceMarker) Invoked when the ExpectedPlace Marker is clicked.
onExpectedPlaceMarkerRemoved(HyperTrackMapFragment hyperTrackMapFragment, String actionID, Marker expectedPlaceMarker) Invoked when the ExpectedPlace Marker is removed.
onMultipleActionsExpectedPlaceMarkerAdded(HyperTrackMapFragment hyperTrackMapFragment, Marker expectedPlaceMarker) Invoked when the Multiple Actions ExpectedPlace Marker is added.
onMultipleActionsExpectedPlaceMarkerClicked(HyperTrackMapFragment hyperTrackMapFragment, Marker expectedPlaceMarker) Invoked when the Multiple Actions ExpectedPlace Marker is clicked.
onMultipleActionsExpectedPlaceMarkerRemoved(HyperTrackMapFragment hyperTrackMapFragment, Marker expectedPlaceMarker) Invoked when the Multiple Actions ExpectedPlace Marker is removed.
onCustomMarkerAdded(HyperTrackMapFragment hyperTrackMapFragment, Marker customMarker) Invoked when a Custom Marker is added.
onCustomMarkerClicked(HyperTrackMapFragment hyperTrackMapFragment, Marker customMarker) Invoked when a Custom Marker is added.
onCustomMarkerRemoved(HyperTrackMapFragment hyperTrackMapFragment, Marker customMarker) Invoked when a Custom Marker is removed.
onCallButtonClicked(HyperTrackMapFragment hyperTrackMapFragment, String actionID) Invoked when the Call button on the user info view is clicked.
onActionStatusChanged(List changedStatusActionIds, List changedStatusActions) Invoked when status of any action changes.
onActionRefreshed(List refreshedActionIds, List refreshedActions) Invoked when data of any action refreshed.
onExpectedPlaceSelected(Place expectedPlace) Invoked when place is selected using the "Select a Place" widget.

Other Utility methods

HyperTrackUtils classes provides the following utility methods:

Method Returns Description
HyperTrackUtils.isPublishableKeyConfigured(Context) boolean Returns true if HyperTrack SDK's Publishable Key has been configured, false otherwise.
HyperTrackUtils.getLocationProvider(Context) String Returns the device's location provider (one of LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER or LocationManager.PASSIVE_PROVIDER), null if location is disabled.
HyperTrackUtils.getLocationAccuracy(Context) int Returns the device's location accuracy (one of HyperTrackUtils's constants: LOCATION_MODE_HIGH_ACCURACY, LOCATION_MODE_SENSORS_ONLY or LOCATION_MODE_BATTERY_SAVING), LOCATION_MODE_OFF if location is disabled.
HyperTrackUtils.isLocationAccuracyHigh(Context) boolean Returns true if device's location accuracy is LOCATION_MODE_HIGH_ACCURACY, false otherwise.
HyperTrackUtils.isInternetConnected(Context) boolean Returns true if internet connectivity is available, false otherwise.
HyperTrackUtils.isWifiEnabled(Context) boolean Returns true if internet connection is WiFi (Un-Metered), false otherwise.
HyperTrackUtils.isPlayServicesAvailable(Context) boolean Returns true if Google PlayServices is available on the device, false otherwise.

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""