public class

IDigiServiceManager

extends Object
java.lang.Object
   ↳ com.digi.android.idigi.library.core.IDigiServiceManager

Class Overview

This class provides access to the iDigi specific API and other common useful methods in any Android application. The service is instantiated as follows:

 IDigiServiceManager iDigiServiceManager = new IDigiServiceManager();
 

Summary

Public Constructors
IDigiServiceManager(Context applicationContext)
Public Methods
String getDeviceID()
Retrieves the device ID.
HashMap<StringIDoCommandListener> getDoCommandListeners()
Returns a Map with the target as key and the IDocommandListener subscribed to that target as value.
String getErrorMessage()
Returns a String containing the latest error message generated.
static IDigiServiceManager getInstance()
Returns the IDigiServiceManager instance.
String getServiceVersion()
Returns a String containing the iDigi service version.
static boolean isEmulator()
Returns whether or not the Android device is a virtual device.
boolean isServiceInstalled()
Returns whether or not the iDigi service is installed in the Android device.
boolean isServiceRunning()
Returns whether or not the iDigi service is running in the Android device.
boolean sendFile(String destPath, String localPath, boolean async)
Sends to iDigi the file located in the given path.
boolean sendFile(String destPath, String localPath, boolean async, int timeout)
Sends to iDigi the file located in the given path.
boolean sendFile(String destPath, String localPath)
Sends to iDigi the file located in the given path.
boolean sendSample(String destPath, Sample sample, boolean async)
Sends a measured sample to iDigi in order to be stored in the samples Data Base.
boolean sendSample(String destPath, Sample sample)
Sends a measured sample to iDigi in order to be stored in the samples Data Base.
boolean sendSample(String destPath, Sample sample, boolean async, int timeout)
Sends a list of measured samples to iDigi in order to be stored in the samples Data Base.
boolean sendSamples(String destPath, ArrayList<Sample> samples, boolean async)
Sends a list of measured samples to iDigi in order to be stored in the samples Data Base.
boolean sendSamples(String destPath, ArrayList<Sample> samples, boolean async, int timeout)
Sends a list of measured samples to iDigi in order to be stored in the samples Data Base.
boolean sendSamples(String destPath, ArrayList<Sample> samples)
Sends a list of measured samples to iDigi in order to be stored in the samples Data Base.
boolean sendTextFile(String destPath, String data, boolean async, int timeout)
Sends a file to iDigi with the given name and text.
boolean sendTextFile(String destPath, String data)
Sends a file to iDigi with the given name and text.
boolean sendTextFile(String destPath, String data, boolean async)
Sends a file to iDigi with the given name and text.
void startService()
Starts the iDigi service.
void subscribeDoCommand(String target, IDoCommandListener listener)
Adds the given IDoCommandListener to the list of listeners to be notified when a do_command is received in the associated listener target.
void unsubscribeDoCommand(String target)
Removes the IDoCommandListener that is subscribed to the given target.
Protected Methods
void setDeviceID(String deviceID)
Sets the device ID.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public IDigiServiceManager (Context applicationContext)

Public Methods

public String getDeviceID ()

Retrieves the device ID.

Returns
  • The device ID.

public HashMap<StringIDoCommandListener> getDoCommandListeners ()

Returns a Map with the target as key and the IDocommandListener subscribed to that target as value.

Returns
  • The Map containing the targets and subscribed IDocmmandListeners.

public String getErrorMessage ()

Returns a String containing the latest error message generated.

Returns
  • The error message.

public static IDigiServiceManager getInstance ()

Returns the IDigiServiceManager instance.

Returns
  • The instance of the IDigiServiceManager.

public String getServiceVersion ()

Returns a String containing the iDigi service version.

Returns
  • The iDigi service version.

public static boolean isEmulator ()

Returns whether or not the Android device is a virtual device.

Returns
  • True if the Android device is a virtual device, false otherwise.

public boolean isServiceInstalled ()

Returns whether or not the iDigi service is installed in the Android device.

Returns
  • True if the iDigi service is installed, false otherwise.

public boolean isServiceRunning ()

Returns whether or not the iDigi service is running in the Android device.

Returns
  • True if the iDigi service is running, false otherwise.

public boolean sendFile (String destPath, String localPath, boolean async)

Sends to iDigi the file located in the given path.

Parameters
destPath Path and name of the file to be sent.
localPath Path containing the file to be uploaded.
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public boolean sendFile (String destPath, String localPath, boolean async, int timeout)

Sends to iDigi the file located in the given path.

Parameters
destPath Path and name of the file to be sent.
localPath Path containing the file to be uploaded.
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
timeout The number of milliseconds the method will wait for the status of the send file action.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public boolean sendFile (String destPath, String localPath)

Sends to iDigi the file located in the given path. The transfer method is asynchronous.

Parameters
destPath Path and name of the file to be sent.
localPath Path containing the file to be uploaded.
Returns
  • Always true.

public boolean sendSample (String destPath, Sample sample, boolean async)

Sends a measured sample to iDigi in order to be stored in the samples Data Base. The sample needs to be stored in a temp file first, so a destiny path is also needed.

Parameters
destPath Path and name of the file to be sent.
sample The sample to store in iDigi
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public boolean sendSample (String destPath, Sample sample)

Sends a measured sample to iDigi in order to be stored in the samples Data Base. The sample needs to be stored in a temp file first, so a destiny path is also needed.

Parameters
destPath Path and name of the file to be sent.
sample The sample to store in iDigi
Returns
  • Always true

public boolean sendSample (String destPath, Sample sample, boolean async, int timeout)

Sends a list of measured samples to iDigi in order to be stored in the samples Data Base. The sample needs to be stored in a temp file first, so a destiny path is also needed.

Parameters
destPath Path and name of the file to be sent.
sample The sample to store in iDigi
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
timeout The number of milliseconds the method will wait for the status of the send sample action.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public boolean sendSamples (String destPath, ArrayList<Sample> samples, boolean async)

Sends a list of measured samples to iDigi in order to be stored in the samples Data Base. The samples need to be stored in a temp file first, so a destiny path is also needed.

Parameters
destPath Path and name of the file to be sent.
samples The list of samples to store in iDigi
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public boolean sendSamples (String destPath, ArrayList<Sample> samples, boolean async, int timeout)

Sends a list of measured samples to iDigi in order to be stored in the samples Data Base. The samples need to be stored in a temp file first, so a destiny path is also needed.

Parameters
destPath Path and name of the file to be sent.
samples The list of samples to store in iDigi
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
timeout The number of milliseconds the method will wait for the status of the send samples action.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public boolean sendSamples (String destPath, ArrayList<Sample> samples)

Sends a list of measured samples to iDigi in order to be stored in the samples Data Base. The samples need to be stored in a temp file first, so a destiny path is also needed.

Parameters
destPath Path and name of the file to be sent.
samples The list of samples to store in iDigi
Returns
  • Always true.

public boolean sendTextFile (String destPath, String data, boolean async, int timeout)

Sends a file to iDigi with the given name and text.

Parameters
destPath Path and name of the file to be sent.
data Text contents of the file.
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
timeout The number of milliseconds the method will wait for the status of the send file action.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public boolean sendTextFile (String destPath, String data)

Sends a file to iDigi with the given name and text. The transfer method is asynchronous.

Parameters
destPath Path and name of the file to be sent.
data Text contents of the file.
Returns
  • True.

public boolean sendTextFile (String destPath, String data, boolean async)

Sends a file to iDigi with the given name and text.

Parameters
destPath Path and name of the file to be sent.
data Text contents of the file.
async Indicates whether the transfer will be asynchronous (true) or synchronous (false). If it is synchronous, the manager will block until a response is received or the timeout expires.
Returns
  • True if the file was sent successfully, false otherwise. If async is configured as true, the method will always return true.

public void startService ()

Starts the iDigi service.

public void subscribeDoCommand (String target, IDoCommandListener listener)

Adds the given IDoCommandListener to the list of listeners to be notified when a do_command is received in the associated listener target.

Parameters
target The target that the IDoCommandListener will subscribe.
listener IDoCommandListener to be added.

public void unsubscribeDoCommand (String target)

Removes the IDoCommandListener that is subscribed to the given target.

Parameters
target Target that the IDoCommandListener to be removed is bound.

Protected Methods

protected void setDeviceID (String deviceID)

Sets the device ID.

Parameters
deviceID The device ID.