com.octoshape.android.client
Class OctoStatic

java.lang.Object
  extended by com.octoshape.android.client.OctoStatic

public class OctoStatic
extends java.lang.Object

Contains static methods to initialize the OctoshapeSystem.


Method Summary
static OctoshapeSystem create(Context context, ProblemListener problemListener, OctoshapePortListener portListener)
          Creates the OctoshapeSystem.
static void enableLog(boolean toConsole, java.lang.String filePath)
          Enables the logging for the OctoshapeSystem and OctoshapeService.
static Problem generateMediaPlayerProblem(int what, int extra)
          Method for generating Problem instances from Android MediaPlayer errors.
static void terminate(java.lang.Runnable runOnFinish)
          Terminates the OctoshapeSystem and unbinds from the Octoshape Service.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static OctoshapeSystem create(Context context,
                                     ProblemListener problemListener,
                                     OctoshapePortListener portListener)
Creates the OctoshapeSystem.

Creating the OctoshapeSystem object requires the presence of the StreamService service in the Android manifest file:

Only the first call to this method does anyhting; subsequent calls will return the OctoshapeSystem object already created and ignore their parameters.

Parameters:
context - required for binding the Octoshape service, once OctoshapeSystem.open() is called.
problemListener - for the OctoshapeSystem and the Octoshape Servive. It is recommended to handle problems from the OctoshapeSystem by showing a text message to the user @see Problem.
portListener - for reporting successful launch and bindpoint of the Octoshape client. This may be NULL, if this information is not needed (see OctoshapePortListener.
Returns:

generateMediaPlayerProblem

public static Problem generateMediaPlayerProblem(int what,
                                                 int extra)
Method for generating Problem instances from Android MediaPlayer errors.

For details please see the MediaPlayer.OnErrorListener documentation.

Parameters:
what - the type of error that has occurred.
extra - an extra code, specific to the error. Typically implementation dependent.

terminate

public static void terminate(java.lang.Runnable runOnFinish)
Terminates the OctoshapeSystem and unbinds from the Octoshape Service.

This OctoshapeSystem instance must not be used after this method has been called.

The Octoshape System should be terminated after use (e.g, when the application or activity is destroyed), even if #open has not been called.

Parameters:
runOnFinish - If different from null, this is called when the class switches to closed state.

enableLog

public static void enableLog(boolean toConsole,
                             java.lang.String filePath)
Enables the logging for the OctoshapeSystem and OctoshapeService. For enabling logging for the client please refer to the SDK documentation.

Must be called before create the OctoshapeSystem object to have any effect.

Enabling debuging requires starting the service in debug mode. This is done by replacing <service android:name="com.octoshape.android.service.StreamService" android:process=":OctoProc"/> with: <service android:name="com.octoshape.android.service.StreamServiceDebug" android:process=":OctoProc"/>

Parameters:
toConsole - If true the log will be written to the console.
filePath - If non-null the log will be written to a file in the given folder.