Java Reference
In-Depth Information
Figure 15-3.
Supporting classes for communication with contactless targets
Unfortunately, implementing
Connection
is where uniformity between the various
subclasses ends. The API takes a message-oriented approach to communicating with
contactless targets, but the methods differ between the types of targets:
• NDEF-enabled devices use the
javax.microedition.contactless.ndef.
NDEFTagConnection
class to exchange
NDEFMessage
instances via the connection's
readNDEF
and
writeNDEF
methods.
• ISO 14443-enabled devices use the
javax.microedition.contactless.sc.
ISO14443Connection
class and its
exchangeData
method to exchange raw arrays
of bytes.
• Generic RFID devices use the
javax.microedition.rf.PlainTagConnection
class.
Instances of this class exchange vectors of Java objects using the
tranceive
method.
These Java objects are defined by extensions to the API that encapsulate application-
specific data.
• Visual tags can be encoded and decoded using the
javax.microedition.
contactless.visual.VisualTagConnection
class, which actually doesn't connect to
anything. (I say more about this class in the next section.)