public class HyperTrack
extends java.lang.Object
Usage:
HyperTrack sdk = HyperTrack.getInstance(myPublishableKey)
.setDeviceName("Elvis")
.allowMockLocations()
.addTrackingListener(this);
Log.d(TAG, "HyperTrack device id is " + sdk.getDeviceID());
sdk.start();
See our awesome quickstart for details.
Modifier and Type | Field and Description |
---|---|
CoreSDKProvider |
mSdkProvider |
Modifier and Type | Method and Description |
---|---|
GeotagResult |
addGeotag(java.util.Map<java.lang.String,?> payload)
Convenience alias to
addGeotag(Map, Location) with null expected location. |
GeotagResult |
addGeotag(java.util.Map<java.lang.String,?> payload,
android.location.Location expected)
Creates geotag with configurable payload.
|
HyperTrack |
addTrackingListener(TrackingStateObserver.OnTrackingStateChangeListener listener)
Sets listener, that will be notified when tracking starts/stops or significant error occurred.
|
HyperTrack |
allowMockLocations()
Allows you to use location mocking software (e.g.
|
HyperTrack |
backgroundTrackingRequirement(boolean isRequired)
Sets whether to request background location permission on Android 11 and later.
|
static void |
enableDebugLogging()
Enables debug log output.
|
static java.util.Set<Blocker> |
getBlockers() |
void |
getCurrentLocation(AsyncResultReceiver<android.location.Location,OutageReason> receiver)
Asynchronous access to the current device location.
|
java.lang.String |
getDeviceID() |
static HyperTrack |
getInstance(java.lang.String publishableKey)
Entry point to SDK usage.
|
Result<android.location.Location,OutageReason> |
getLatestLocation()
Latest device location, that is known to HyperTrack SDK.
|
boolean |
isRunning() |
HyperTrack |
removeTrackingListener(TrackingStateObserver.OnTrackingStateChangeListener listener)
Removes listener or does nothing, if null was passed in as argument.
|
HyperTrack |
requestPermissionsIfNecessary()
Convenience method that will issue required permissions request dialog if necessary.
|
HyperTrack |
setDeviceMetadata(java.util.Map<java.lang.String,java.lang.Object> metaData)
Sets current device data, that can be used for easier dashboard navigation or grouping
of location data in tag groups style.
|
HyperTrack |
setDeviceName(java.lang.String name)
Sets current device name, that can be used for easier dashboard navigation.
|
HyperTrack |
setTrackingNotificationConfig(ServiceNotificationConfig config)
Allows to to customize persistent notification elements.
|
HyperTrack |
start()
Starts tracking, if all requirements are met (permissions are granted and publisahble Key is validated).
|
HyperTrack |
stop()
Stops current tracking session.
|
HyperTrack |
syncDeviceSettings()
This method checks with HyperTrack cloud whether to start or stop tracking.
|
public static void enableDebugLogging()
public static HyperTrack getInstance(@NonNull java.lang.String publishableKey) throws java.lang.IllegalArgumentException
publishableKey
- Get it from HyperTrack dashboard.
It is only used in first invocation, so providing different keys during
one application session will have no effect.java.lang.IllegalArgumentException
- if null or empty publishable key was passed in.@NonNull public GeotagResult addGeotag(@NonNull java.util.Map<java.lang.String,?> payload)
addGeotag(Map, Location)
with null expected location.@NonNull public GeotagResult addGeotag(@NonNull java.util.Map<java.lang.String,?> payload, @Nullable android.location.Location expected)
payload
- key-value pairs.expected
- location where the geotagging action is supposed to happen.for more.
public HyperTrack requestPermissionsIfNecessary()
public HyperTrack start()
addTrackingListener(TrackingStateObserver.OnTrackingStateChangeListener)
it will call TrackingStateObserver.OnTrackingStateChangeListener.onError(TrackingError)
if tracking wasn't started or
TrackingStateObserver.OnTrackingStateChangeListener.onTrackingStart()
otherwise.public HyperTrack stop()
addTrackingListener(TrackingStateObserver.OnTrackingStateChangeListener)
it will call TrackingStateObserver.OnTrackingStateChangeListener.onTrackingStop()
on success.public java.lang.String getDeviceID()
public boolean isRunning()
public HyperTrack allowMockLocations()
public HyperTrack backgroundTrackingRequirement(boolean isRequired)
public HyperTrack setTrackingNotificationConfig(@Nullable ServiceNotificationConfig config)
config
- tracking notification parameters. See ServiceNotificationConfig
for details.public HyperTrack setDeviceName(@Nullable java.lang.String name)
addGeotag(Map)
for passing that data.name
- that will be visible in Dashboard.public HyperTrack setDeviceMetadata(@Nullable java.util.Map<java.lang.String,java.lang.Object> metaData)
addGeotag(Map)
for passing that data.metaData
- - key-value pairs.public HyperTrack addTrackingListener(@Nullable TrackingStateObserver.OnTrackingStateChangeListener listener) throws java.lang.IllegalArgumentException
TrackingError.INVALID_PUBLISHABLE_KEY_ERROR
will
be delivered to litener's TrackingStateObserver.OnTrackingStateChangeListener.onError(TrackingError)
callback.
Does nothing when invoked with null argument.listener
- that will be used to deliver notifications.java.lang.IllegalArgumentException
removeTrackingListener(TrackingStateObserver.OnTrackingStateChangeListener)
public HyperTrack removeTrackingListener(@Nullable TrackingStateObserver.OnTrackingStateChangeListener listener) throws java.lang.IllegalArgumentException
listener
- to remove.java.lang.IllegalArgumentException
addTrackingListener(TrackingStateObserver.OnTrackingStateChangeListener)
public HyperTrack syncDeviceSettings()
@NonNull public Result<android.location.Location,OutageReason> getLatestLocation()
Device location is constantly refreshed while the sdk is tracking, so the returned location represents current device location. Since the sdk uses accelerometer, gyroscope and other sensor data to optimize power consumption, this could be location computed seconds or minutes ago. If the location can't be retrieved for whatever reason (SDK isn't tracking, missing permissions, location services were disabled etc) null is returned.
()
public void getCurrentLocation(@NonNull AsyncResultReceiver<android.location.Location,OutageReason> receiver)