public abstract class Zendrive
extends java.lang.Object
public class MyActivity extends Activity {
...
static final String ZENDRIVE_SDK_KEY_STRING = ...
...
public void setupZendriveSDK(View v){
...
ZendriveConfiguration zendriveConfiguration = new ZendriveConfiguration(
ZENDRIVE_SDK_KEY_STRING, driverId);
Zendrive.setup(this.getApplicationContext(),
zendriveConfiguration, MyZendriveIntentService.class,
new ZendriveOperationCallback() {
@Override
public void onCompletion(ZendriveOperationResult result) {
if (result.isSuccess()) {
Log.d(MY_APP_TAG, "Zendrive is setup.");
}
}
}
);
}
...
}
Other than setup, all methods are optional to call by the application. They are also no-ops
in case setup has not been called. All methods are threadsafe.Modifier and Type | Method and Description |
---|---|
static ActiveDriveInfo |
getActiveDriveInfo()
Get info on the currently active drive.
|
static java.lang.String |
getBuildVersion()
Returns an identifier which can be used to identify this SDK build.
|
static java.util.Map<ZendriveEventType,java.lang.Boolean> |
getEventSupportForDevice(android.content.Context context)
Check whether the
zendrive event types are supported or not on this
device |
static ZendriveState |
getZendriveState()
Get the current state of the Zendrive SDK.
|
static boolean |
isAccidentDetectionSupported(android.content.Context context)
Is Zendrive collision detection supported on this device?
|
static boolean |
isSDKSetup()
Is the Zendrive SDK already setup?
|
static boolean |
isValidInputParameter(java.lang.String input)
Checks whether the string passed to the SDK is valid.
|
static void |
setup(android.content.Context context,
ZendriveConfiguration zendriveConfiguration,
java.lang.Class<? extends ZendriveBroadcastReceiver> broadcastReceiverClass,
java.lang.Class<? extends ZendriveNotificationProvider> notificationProviderClass,
ZendriveOperationCallback callback)
Setup the Zendrive SDK with a configuration and a intent service for SDK callbacks.
|
static void |
setZendriveDriveDetectionMode(ZendriveDriveDetectionMode driveDetectionMode,
ZendriveOperationCallback callback)
Use this method to change the
ZendriveDriveDetectionMode after SDK is already setup. |
static void |
startDrive(java.lang.String trackingId,
ZendriveOperationCallback callback)
Manually start recording a drive.
|
static ZendriveOperationResult |
startSession(java.lang.String sessionId)
Start a session in the SDK.
|
static void |
stopDrive(java.lang.String trackingId,
ZendriveOperationCallback callback)
Stop the currently active manually started drive.
|
static ZendriveOperationResult |
stopSession()
Stop currently ongoing session.
|
static void |
teardown(ZendriveOperationCallback callback)
Shuts down the Zendrive framework.
|
static void |
triggerMockAccident(android.content.Context context,
ZendriveAccidentConfidence confidence,
ZendriveOperationCallback callback)
Triggers a fake accident.
|
static ZendriveOperationResult |
uploadAllDebugDataAndLogs()
Allows an application to trigger a bulk upload of all SDK data on the device to Zendrive
for debugging purposes.
|
static void |
wipeOut(android.content.Context context,
ZendriveOperationCallback callback)
Wipe out all the data that zendrive keeps locally on the device.
|
public static void setup(android.content.Context context, ZendriveConfiguration zendriveConfiguration, java.lang.Class<? extends ZendriveBroadcastReceiver> broadcastReceiverClass, java.lang.Class<? extends ZendriveNotificationProvider> notificationProviderClass, ZendriveOperationCallback callback)
ZendriveConfiguration
is a no-op. If provided,
the ZendriveBroadcastReceiver
class will be sent SDK
callbacks after the call. If either the 'sdkKey' or 'driverId' in the
ZendriveConfiguration
changes between the
previous setup call and this one, it will be the same as calling
teardown(ZendriveOperationCallback)
followed by calling setup with the new parameters.
Once setup finishes, the ZendriveOperationCallback
is called (if provided) with
the result of the setup operation. Callback will be made on calling thread if it's
Looper
is already prepared, else the callback is made on the Main Thread.
In addition to the callback, the SDK also issues a broadcast intent after setup.
The application can listen to this broadcast to take any post setup actions.
On setup success, the intent action is of the format -
application_package_name.ZENDRIVE.SETUP_SUCCESS or
application_package_name.ZENDRIVE.SETUP_FAILURE.
For example - "com.zendrive.sample.ZENDRIVE_SETUP_SUCCESS" and
"com.zendrive.sample.ZENDRIVE_SETUP_FAILURE" are the intent actions for an app running
with the package "com.zendrive.sample".context
- is the context object of the enclosing application.zendriveConfiguration
- The configuration properties to setup the Zendrive SDK.
Cannot be null.broadcastReceiverClass
- A intent service which receives callbacks from the SDK. It
receives updates about interesting events like start and
end of a drive, accident detected etc from the SDK.
Specify null if you don't want to receive callbacks from
the SDK.notificationProviderClass
- A ZendriveNotificationProvider class that is used to fetch
notifications when the sdk goes foreground.callback
- The callback to be invoked after setup. It will be invoked
on the same thread where setup is called. This can be 'null'
if no callback is desired by the application.public static void teardown(ZendriveOperationCallback callback)
setup(Context, ZendriveConfiguration, Class, Class, ZendriveOperationCallback)
setup} has not been called.
Once teardown finishes, the ZendriveOperationCallback
is called (if provided) with
the result of the teardown operation. Callback will be made on calling thread if it's
Looper
is already prepared, else the callback is made on the Main Thread.
N.B. the library is typically very conservative about what modules of
the phone it uses for tracking and how much memory it uses etc. and as
such is very conservative about memory and battery impact. So this
method should not really be called to save power / memory for the
application.public static void setZendriveDriveDetectionMode(ZendriveDriveDetectionMode driveDetectionMode, ZendriveOperationCallback callback)
ZendriveDriveDetectionMode
after SDK is already setup.
Applications which do not want the SDK to continuously track drives in
background should set this value to AUTO_OFF. With this, the
application needs to call startDrive(java.lang.String, com.zendrive.sdk.ZendriveOperationCallback)
method to record drives.
In case the application wants to enable auto drive detection only for a fixed duration
(like when the driver is on-duty), use this method to change the mode to AUTO_ON for that
period and set it back to AUTO_OFF (once the driver goes off-duty).
Once setup finishes, the ZendriveOperationCallback
is called (if provided) with
the result of the setup operation. Callback will be made on calling thread if it's
Looper
is already prepared, else the callback is made on the Main Thread.driveDetectionMode
- The new drive detection mode. If this is the same as the current
ZendriveDriveDetectionMode, then this call is a no-op.callback
- called with the result of the operation when completed. In case
of any
error encountered, the result contains the relevant error details.public static void startDrive(java.lang.String trackingId, ZendriveOperationCallback callback)
stopDrive(java.lang.String, com.zendrive.sdk.ZendriveOperationCallback)
to indicate the end of the drive. These methods should
be used when the application has explicit knowledge of the start and end
of a drive. In such applications, using this call is recommended).
When startDrive is called with a manually recorded drive in progress, if trackingId
matches the ongoing drive's trackingId, this call is a no-op. If the trackingIds do not
match, stopDrive(java.lang.String, com.zendrive.sdk.ZendriveOperationCallback)
is called implicitly before a new drive is
started.
Callback will be made on calling thread if it's Looper
is already
prepared, else the callback is made on the Main Thread.trackingId
- an identifier which allows identifying this drive uniquely. This identifier
must be unique for this user. It may not be null or a empty string. It will
be truncated to 64 characters if it is longer than 64 characters.
Passing invalid trackingId is an error
.callback
- called with the result of the operationpublic static void stopDrive(java.lang.String trackingId, ZendriveOperationCallback callback)
startDrive(java.lang.String, com.zendrive.sdk.ZendriveOperationCallback)
and stopDrive calls are not counted.
i.e stopDrive will stop a manually started drive irrespective of how many times
startDrive(java.lang.String, com.zendrive.sdk.ZendriveOperationCallback)
is called.
This call has no effect on an automatically detected drive that may be in progress.
Callback will be made on calling thread if it's Looper
is already
prepared, else the callback is made on the Main Thread.trackingId
- This identifier should match the trackingId sent to
startDrive(java.lang.String, com.zendrive.sdk.ZendriveOperationCallback)
method while starting the current
drive. If the trackingIds do not match, this function is a no-op.
Cannot be null or empty string.callback
- called with the result of the operation when completedpublic static ZendriveOperationResult startSession(java.lang.String sessionId)
stopSession()
when it wants to end the session.
Only one session may be active at a time. Calling startSession when a session is already
active will terminate the ongoing session and start a new one with the given id.sessionId
- an identifier that identifies this session uniquely. It may not be null
or an empty string. It may not be longer than 64 characters.
Passing invalid sessionId is a no-op
.public static ZendriveOperationResult stopSession()
startSession(String)
public static boolean isValidInputParameter(java.lang.String input)
input
- The string to validatepublic static boolean isSDKSetup()
public static void triggerMockAccident(android.content.Context context, ZendriveAccidentConfidence confidence, ZendriveOperationCallback callback)
ZendriveOperationCallback
is called (if provided) with
the result of the setup operation. Callback will be made on calling thread if it's
Looper
is already prepared, else the callback is made on the Main Thread.context
- is the context object of the enclosing applicationconfidence
- is the confidence level of the accident to triggercallback
- called with the result of the operation when completed. In case of any
error encountered, the result contains the relevant error details.public static java.lang.String getBuildVersion()
public static boolean isAccidentDetectionSupported(android.content.Context context)
public static java.util.Map<ZendriveEventType,java.lang.Boolean> getEventSupportForDevice(android.content.Context context)
zendrive event types
are supported or not on this
devicepublic static ZendriveOperationResult uploadAllDebugDataAndLogs()
public static void wipeOut(android.content.Context context, ZendriveOperationCallback callback)
teardown(ZendriveOperationCallback)
to tear down a live SDK before making this call.
Callback will be made on calling thread if it's Looper
is already
prepared, else the callback is made on the Main Thread.context
- The context of the enclosing application.callback
- Called with the result of the operation.public static ActiveDriveInfo getActiveDriveInfo()
public static ZendriveState getZendriveState()