|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectService
ioio.lib.util.android.IOIOService
public abstract class IOIOService
A convenience class for easy creation of IOIO-based services.
It is used by creating a concrete Service
in your application, which
extends this class. This class then takes care of proper creation and
abortion of the IOIO connection and of a dedicated thread for IOIO
communication.
In the basic usage the client should extend this class and implement
createIOIOLooper()
, which should return an implementation of the
IOIOLooper
interface. In this implementation, the client implements
the IOIOLooper.setup(ioio.lib.api.IOIO)
method, which gets called as
soon as communication with the IOIO is established, and the
IOIOLooper.loop()
method, which gets called repetitively as long as
the IOIO is connected.
In addition, the IOIOLooper.disconnected()
method may be overridden
in order to execute logic as soon as a disconnection occurs for whichever
reason. The IOIOLooper.incompatible()
method may be overridden in
order to take action in case where a IOIO whose firmware is incompatible with
the IOIOLib version that application is built with.
In a more advanced use case, more than one IOIO is available. In this case, a
thread will be created for each IOIO, whose semantics are as defined above.
If the client needs to be able to distinguish between them, it is possible to
override createIOIOLooper(String, Object)
instead of
createIOIOLooper()
. The first argument provided will contain the
connection class name, such as ioio.lib.impl.SocketIOIOConnection for a
connection established over a TCP socket (which is used over ADB). The second
argument will contain information specific to the connection type. For
example, in the case of SocketIOIOConnection
, the second argument
will contain an Integer
representing the local port number.
Constructor Summary | |
---|---|
IOIOService()
|
Method Summary | |
---|---|
IOIOLooper |
createIOIOLooper(java.lang.String connectionType,
java.lang.Object extra)
Subclasses should implement this method by returning an implementation of IOIOLooper . |
void |
onCreate()
Subclasses should call this method from their own onCreate() if overloaded. |
void |
onDestroy()
Subclasses should call this method from their own onDestroy() if overloaded. |
void |
onStart(Intent intent,
int startId)
Subclasses should call this method from their own onStart() if overloaded. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IOIOService()
Method Detail |
---|
public void onCreate()
public void onDestroy()
public void onStart(Intent intent, int startId)
public IOIOLooper createIOIOLooper(java.lang.String connectionType, java.lang.Object extra)
IOIOLooperProvider
IOIOLooper
. The caller provide enough information to uniquely
identify the connection, through the parameters. null
may be
returned if the client is not interested to create a thread for this
IOIO. This can be used in order to filter out unwanted connections, for
example if the application is only intended for wireless connection, any
wired connection attempts may be rejected, thus saving resources used for
listening for incoming wired connections.
createIOIOLooper
in interface IOIOLooperProvider
connectionType
- A unique name of the connection type. Typically, the
fully-qualified name of the connection class used to connect
to the IOIO.extra
- A connection-type-specific object with extra information on
the specific connection. Should provide information that
enables distinguishing between different IOIO instances using
the same connection class. For example, a Bluetooth connection
type, might have the remote IOIO's Bluetooth name as extra.
IOIOLooper
, or null
to
skip.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |